Skip to content

Commit

Permalink
Changes based on PR review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
joshcanhelp committed May 24, 2018
1 parent e3d7c2a commit 21e6092
Showing 1 changed file with 25 additions and 19 deletions.
44 changes: 25 additions & 19 deletions lib/admin/WP_Auth0_Admin_Features.php
Original file line number Diff line number Diff line change
Expand Up @@ -311,29 +311,35 @@ public function sso_validation( $old_options, $input ) {
$input['sso'] = ( isset( $input['sso'] ) ? $input['sso'] : 0 );
$is_sso = ! empty( $input['sso'] );

if ( $old_options['sso'] !== $input['sso'] && $is_sso ) {
$app_update_failed = true;
$app_token = WP_Auth0_Api_Client::get_client_token();
if ( $app_token ) {
$update_result = WP_Auth0_Api_Client::update_client( $input['domain'], $app_token, $input['client_id'], true );
if ( $update_result ) {
$app_update_failed = false;
}
}
if ( $app_update_failed ) {
$this->add_validation_error(
__( 'The SSO setting for your Application could not be updated automatically. ', 'wp-auth0' ) .
__( 'Check that "Use Auth0 instead of the IdP to do Single Sign On" is turned on in the ', 'wp-auth0' ) .
$this->get_dashboard_link( 'applications/' . $input['client_id'] . '/settings' )
);
}
}

// SLO does not function without SSO so turn off SLO if SSO is off.
if ( ! $is_sso ) {
// SLO does not function without SSO.
unset( $input['singlelogout'] );
}

// If SSO is off or nothing was changed, exit early.
if ( ! $is_sso || $old_options['sso'] === $input['sso'] ) {
return $input;
}

$app_update_success = false;
$app_token = WP_Auth0_Api_Client::get_client_token();
if ( $app_token ) {
$update_result = WP_Auth0_Api_Client::update_client(
$input['domain'],
$app_token,
$input['client_id'],
true
);
$app_update_success = (bool) $update_result;
}
if ( ! $app_update_success ) {
$this->add_validation_error(
__( 'The SSO setting for your Application could not be updated automatically. ', 'wp-auth0' ) .
__( 'Check that "Use Auth0 instead of the IdP to do Single Sign On" is turned on in the ', 'wp-auth0' ) .
$this->get_dashboard_link( 'applications/' . $input['client_id'] . '/settings' )
);
}

return $input;
}

Expand Down

0 comments on commit 21e6092

Please sign in to comment.