Skip to content

Commit

Permalink
Deprecate parameters in the login flow
Browse files Browse the repository at this point in the history
  • Loading branch information
joshcanhelp committed Oct 5, 2018
1 parent 786d250 commit 0f942d1
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
11 changes: 11 additions & 0 deletions lib/WP_Auth0_Users.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
<?php
class WP_Auth0_Users {

/**
* Create a WordPress user with Auth0 data.
*
* @param object $userinfo - User profile data from Auth0.
* @param null|boolean $role - Set the sole as administrator - @deprecated - 3.8.0.
*
* @return int|WP_Error
*/
public static function create_user( $userinfo, $role = null ) {
$email = null;
if ( isset( $userinfo->email ) ) {
Expand Down Expand Up @@ -76,6 +85,8 @@ public static function create_user( $userinfo, $role = null ) {
);

if ( $role ) {
// phpcs:ignore
trigger_error( sprintf( __( '$role parameter is deprecated.', 'wp-auth0' ), __METHOD__ ), E_USER_DEPRECATED );
$user_data['role'] = 'administrator';
}

Expand Down
18 changes: 15 additions & 3 deletions lib/WP_Auth0_UsersRepo.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ public function tokenHasRequiredScopes( $jwt ) {
*
* @param object $userinfo - Profile object from Auth0.
* @param string $token - ID token from Auth0.
* @param null|string $access_token - TODO: Deprecate, not used
* @param null|string $role - TODO: Deprecate, not used
* @param bool $skip_email_verified - TODO: Deprecate, not used
* @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.
*
* @return int|null|WP_Error
*
Expand All @@ -84,6 +84,18 @@ public function tokenHasRequiredScopes( $jwt ) {
* @throws WP_Auth0_RegistrationNotEnabledException
*/
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
);
}

$auth0_sub = $userinfo->sub;
list($strategy) = explode( '|', $auth0_sub );
$opts = WP_Auth0_Options::Instance();
Expand Down

0 comments on commit 0f942d1

Please sign in to comment.