diff --git a/lib/WP_Auth0_UsersRepo.php b/lib/WP_Auth0_UsersRepo.php index c384f6f3..f2e2db34 100644 --- a/lib/WP_Auth0_UsersRepo.php +++ b/lib/WP_Auth0_UsersRepo.php @@ -1,9 +1,29 @@ a0_options = $a0_options; } @@ -11,34 +31,19 @@ public function __construct( WP_Auth0_Options $a0_options ) { /** * Create or join a WP user with an incoming Auth0 one or reject with an exception. * - * @param object $userinfo - Profile object from Auth0. - * @param string $token - ID token from Auth0. - * @param null|string $access_token - @deprecated - 3.8.0. - * @param null|string $role - @deprecated - 3.8.0. - * @param bool $skip_email_verified - @deprecated - 3.8.0. + * @param object $userinfo - Profile object from Auth0. + * @param string $token - ID token from Auth0. * * @return int|null|WP_Error * - * @throws WP_Auth0_CouldNotCreateUserException - * @throws WP_Auth0_EmailNotVerifiedException - * @throws WP_Auth0_RegistrationNotEnabledException + * @throws WP_Auth0_CouldNotCreateUserException - When the user could not be created. + * @throws WP_Auth0_EmailNotVerifiedException - When a users's email is not verified but the site requires it. + * @throws WP_Auth0_RegistrationNotEnabledException - When registration is not turned on for this site. */ - public function create( $userinfo, $token, $access_token = null, $role = null, $skip_email_verified = false ) { - - if ( func_num_args() > 2 ) { - // phpcs:ignore - @trigger_error( - sprintf( - __( '$access_token, $role, and $skip_email_verified params are deprecated.', 'wp-auth0' ), - __METHOD__ - ), - E_USER_DEPRECATED - ); - } + public function create( $userinfo, $token ) { $auth0_sub = $userinfo->sub; list($strategy) = explode( '|', $auth0_sub ); - $opts = WP_Auth0_Options::Instance(); $wp_user = null; $user_id = null; @@ -55,8 +60,7 @@ public function create( $userinfo, $token, $access_token = null, $role = null, $ // Email is considered verified if flagged as such, if we ignore the requirement, or if the strategy is skipped. $email_verified = ! empty( $userinfo->email_verified ) - || $skip_email_verified - || $opts->strategy_skips_verified_email( $strategy ); + || $this->a0_options->strategy_skips_verified_email( $strategy ); // WP user to join with incoming Auth0 user. if ( ! empty( $userinfo->email ) ) { @@ -77,11 +81,11 @@ public function create( $userinfo, $token, $access_token = null, $role = null, $ if ( ! empty( $current_auth0_id ) && $auth0_sub !== $current_auth0_id ) { throw new WP_Auth0_CouldNotCreateUserException( __( 'There is a user with the same email.', 'wp-auth0' ) ); } - } elseif ( $opts->is_wp_registration_enabled() || $opts->get( 'auto_provisioning' ) ) { + } elseif ( $this->a0_options->is_wp_registration_enabled() || $this->a0_options->get( 'auto_provisioning' ) ) { // WP user does not exist and registration is allowed. - $user_id = WP_Auth0_Users::create_user( $userinfo, $role ); + $user_id = WP_Auth0_Users::create_user( $userinfo ); - // Check if user was created + // Check if user was created. if ( is_wp_error( $user_id ) ) { throw new WP_Auth0_CouldNotCreateUserException( $user_id->get_error_message() ); } elseif ( -2 === $user_id ) { @@ -103,7 +107,7 @@ public function create( $userinfo, $token, $access_token = null, $role = null, $ /** * Look for and return a user with an Auth0 ID * - * @param string $id - An Auth0 user ID, like "provider|id" + * @param string $id - An Auth0 user ID, like "provider|id". * * @return null|WP_User */