Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WordPress WooCommerce checkout Auth0 user creation results in error #860

Closed
Johnny99211 opened this issue Dec 1, 2022 · 5 comments
Closed
Assignees

Comments

@Johnny99211
Copy link

Hi,

I've found a script to create an Auth0 user during WooCommerce checkout process. Somehow, the script doesn't work anymore and results in an error:

The user already exists.

This makes absolutely no sense because I've only my admin user, which has totally different data.

This is how I implemented the user creation by using the official Auth0 plugin:

/**
 * Create new Auth0 user on WooCommerce user creation
 */
add_action( 'woocommerce_created_customer', 'woocommerce_created_customer_action', 10, 3 );
function woocommerce_created_customer_action( int $customer_id, array $new_customer_data, string $password_generated ) {
	$a0_options = WP_Auth0_Options::Instance();

	if ( $a0_options === null ) {
		return;
	}

	$payload = [
		'client_id'   => $a0_options->get( 'client_id' ),
		'email'       => $new_customer_data['user_email'],
		'password'    => $new_customer_data['user_pass'],
		'connection'  => 'One-Agency',
	];

	$new_auth0_user = WP_Auth0_Api_Client::signup_user( $a0_options->get_auth_domain(), $payload );

	if ( $new_auth0_user && isset( $new_auth0_user->_id ) ) {
		$new_auth0_user->sub = 'auth0|' . $new_auth0_user->_id;

		unset( $new_auth0_user->_id );

		$user_repo = new WP_Auth0_UsersRepo( $a0_options );
		$user_repo->update_auth0_object( $customer_id, $new_auth0_user );
	}
}

I've done multiple tests with different E-Mail-Addresses, no chance. I'm always getting the same error over and over:

{
  "date": "2022-11-30T20:54:35.677Z",
  "type": "fs",
  "description": "The user already exists.",
  "connection": "One-Agency",
  "connection_id": "con_cAsIH572PEljbV2H",
  "client_id": "37nFzyPceoRCy7oiNTENUyB8yERe3oiY",
  "client_name": "One Agency",
  "ip": "2a01:4f8:151:21f3::2",
  "user_agent": "WordPress 6.1.1 / Other 0.0.0",
  "details": {
    "body": {
      "tenant": "one-agency",
      "client_id": "37nFzyPceoRCy7oiNTENUyB8yERe3oiY",
      "connection": "One-Agency",
      "email": "[email protected]",
      "password": "*****"
    }
  },
  "user_id": "",
  "user_name": "[email protected]",
  "strategy": "auth0",
  "strategy_type": "database",
  "log_id": "90020221130205440734178151960088485880313450616231821330",
  "_id": "90020221130205440734178151960088485880313450616231821330",
  "isMobile": false,
  "id": "90020221130205440734178151960088485880313450616231821330"
}

Since I'm at least very new to Auth0, I've no clue what's going on here. I really hope, that you can hint me in the correct direction.

Also, I'm struggling with updating the user on the account details page. If you may know a class or function I can use here, I would be very glad.

@Johnny99211
Copy link
Author

I need to mention, that I'm using the version from the WP plugin repo. Not sure, what this version here belongs to.

@evansims
Copy link
Member

Hey @Johnny99211 👋 Apologies for the delay — is this still an issue for you? I'll investigate further this week and see if I can reproduce this on my end, if so. A "user already exists" error should only be occurring if the database attached to con_cAsIH572PEljbV2H already has a user by that email address already present. Can you confirm from the Auth0 dashboard that these accounts are not already in your connection store?

@Johnny99211
Copy link
Author

Hello. We’ve decided to cancel our Auth0 subscription. We’re now using a different solution.

@lynnchin
Copy link

lynnchin commented May 1, 2023

Hi @Johnny99211, do you mind to share where did you find the script to create Auth0 user during woocommerce checkout process? Thanks!

@auth0 auth0 deleted a comment from Johnny99211 May 1, 2023
@evansims
Copy link
Member

evansims commented May 1, 2023

Please keep comments respectful. There's no need for insulting or offensive language in GitHub threads. Thank you.

@auth0 auth0 locked as too heated and limited conversation to collaborators May 1, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants