-
Notifications
You must be signed in to change notification settings - Fork 99
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Move SSO checking into Lock init #570
Conversation
39ba35c
to
cb232fb
Compare
@@ -372,6 +372,19 @@ public function render_form( $html ) { | |||
return $html; | |||
} | |||
|
|||
// If the user has a WP session, determine where they should end up and redirect. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't show a blank, unhelpful login page if the user is already logged in (#414).
@@ -134,13 +134,8 @@ protected function build_settings( $settings ) { | |||
|
|||
public function get_sso_options() { | |||
$options['scope'] = WP_Auth0_LoginManager::get_userinfo_scope( 'sso' ); | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is only ever used for SSO, which uses the hybrid auth (modified implicit) so there's never a need for a code callback processing.
add_action( 'wp_footer', array( $this, 'auth0_singlelogout_footer' ) ); | ||
add_action( 'admin_footer', array( $this, 'auth0_singlelogout_footer' ) ); | ||
add_action( 'login_footer', array( $this, 'auth0_singlelogout_footer' ) ); | ||
add_action( 'wp_login', array( $this, 'end_session' ) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deprecated in #557 but not removed from the login page.
@@ -90,11 +90,9 @@ public function init() { | |||
add_action( 'login_init', array( $this, 'login_auto' ) ); | |||
add_action( 'template_redirect', array( $this, 'init_auth0' ), 1 ); | |||
add_action( 'wp_logout', array( $this, 'logout' ) ); | |||
add_filter( 'login_message', array( $this, 'auth0_sso_footer' ) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removes the existing SSO template templates/auth0-sso-handler-lock10.php
cb232fb
to
0288c66
Compare
WP_Auth0.php
Outdated
@@ -372,6 +372,18 @@ public function render_form( $html ) { | |||
return $html; | |||
} | |||
|
|||
// If the user has a WP session, determine where they should end up and redirect. | |||
if ( is_user_logged_in() ) { | |||
$login_redirect = ! empty( $_REQUEST['redirect_to'] ) ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think in logic usually best to avoid extra operands, you don't need the !
if you switch the Ternary values.
@cocojoe - Fixed up, tinkered with |
Codecov Report
@@ Coverage Diff @@
## master #570 +/- ##
============================================
+ Coverage 15.75% 19.95% +4.19%
+ Complexity 1541 1416 -125
============================================
Files 66 53 -13
Lines 5320 4541 -779
============================================
+ Hits 838 906 +68
+ Misses 4482 3635 -847
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM Also good bump in test coverage.
@cocojoe - Bump is kind of fake as I removed a few external libraries from the test calculation ... don't tell anyone! |
Changes
Moving the SSO processing from a separately-included HTML template into the Lock init JS file.
templates/auth0-sso-handler-lock10.php
fileassets/js/lock-init.js
to hide the Lock form until the SSO check is completewp-login.php
page if they are already logged inReferences
Closes #508
Closes #414
Testing
Testing steps:
wp-login.php
pageExpected
No Lock form shows and you're redirected to the default login link with a WP session and no JS console errors.
wp-login.php
page againYou're redirected to the default login link with the WP session intact.
Checklist