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

Deprecate unused login methods and props #557

Merged
merged 3 commits into from
Oct 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 38 additions & 18 deletions lib/WP_Auth0_LoginManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class WP_Auth0_LoginManager {
/**
* Should the new user have an administrator role?
*
* TODO: Deprecate, not used
* @deprecated - 3.8.0
*
* @var bool|null
*/
Expand All @@ -33,7 +33,7 @@ class WP_Auth0_LoginManager {
/**
* Ignore verified email requirement in Settings > Advanced.
*
* TODO: Deprecate, not used
* @deprecated - 3.8.0
*
* @var bool
*/
Expand All @@ -51,24 +51,33 @@ class WP_Auth0_LoginManager {
*
* @param WP_Auth0_UsersRepo $users_repo - see member variable doc comment.
* @param WP_Auth0_Options|null $a0_options - see member variable doc comment.
* @param null|bool $admin_role - see member variable doc comment.
* @param bool $ignore_unverified_email - see member variable doc comment.
* @param null|bool $admin_role - @deprecated - 3.8.0.
* @param bool $ignore_unverified_email - @deprecated - 3.8.0.
*/
public function __construct(
WP_Auth0_UsersRepo $users_repo,
$a0_options = null,
$admin_role = null,
$ignore_unverified_email = false
) {
$this->admin_role = $admin_role;
$this->ignore_unverified_email = $ignore_unverified_email;
$this->users_repo = $users_repo;
$this->users_repo = $users_repo;

if ( $a0_options instanceof WP_Auth0_Options ) {
$this->a0_options = $a0_options;
} else {
$this->a0_options = WP_Auth0_Options::Instance();
}

$this->admin_role = $admin_role;
$this->ignore_unverified_email = $ignore_unverified_email;

if ( func_num_args() > 2 ) {
// phpcs:ignore
trigger_error(
sprintf( __( '$admin_role and $ignore_unverified_email are deprecated.', 'wp-auth0' ), __METHOD__ ),
E_USER_DEPRECATED
);
}
}

/**
Expand Down Expand Up @@ -625,17 +634,6 @@ public function auth0_singlelogout_footer() {
}
}

/**
* End the PHP session.
*
* TODO: Deprecate
*/
public function end_session() {
if ( session_id() ) {
session_destroy();
}
}

/**
* Get and filter the scope used for access and ID tokens.
*
Expand Down Expand Up @@ -774,6 +772,28 @@ protected function die_on_login( $msg = '', $code = 0, $login_link = true ) {
);
}

/*
*
* DEPRECATED
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why this flying on its own away from a valid method?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not, just a section indicator, everything below is deprecated

*
*/

/**
* End the PHP session.
*
* @deprecated - 3.8.0, not used and no replacement provided.
*
* @codeCoverageIgnore - Deprecated
*/
public function end_session() {
// phpcs:ignore
trigger_error( sprintf( __( 'Method %s is deprecated.', 'wp-auth0' ), __METHOD__ ), E_USER_DEPRECATED );

if ( session_id() ) {
session_destroy();
}
}

/**
* Login using oauth/ro endpoint
*
Expand Down
5 changes: 1 addition & 4 deletions lib/WP_Auth0_Settings_Section.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,5 @@ public function init_menu() {
}
}

// TODO: deprecate
public function redirect_to_help() {

}
public function redirect_to_help() {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it worthy to add the deprecated docblock here as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not entirely sure what to do with it yet. Serves no purpose but is used in a hook above. Will address when this class gets a once-over 👍

}
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 role 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