Merge pull request #19 from rwasef1830/keep_oidc_button_on_login_with_error

In case of an error redirect and auto sso, keep the button and hide the normal form
isekai
Jonathan Daggerhart 8 years ago committed by GitHub
commit ef97d0b8b8

@ -70,19 +70,22 @@ class OpenID_Connect_Generic_Login_Form {
$settings = $this->settings; $settings = $this->settings;
// errors and auto login can't happen at the same time // errors and auto login can't happen at the same time
if ( isset( $_GET['login-error'] ) ) { $message = '';
$message = $this->make_error_output( $_GET['login-error'], $_GET['message'] ); if ( $settings->login_type == 'auto' ) {
} if ( ! isset( $_GET['login-error'] ) ) {
else if ( $settings->login_type == 'auto' ) { wp_redirect( $this->client_wrapper->get_authentication_url() );
wp_redirect( $this->client_wrapper->get_authentication_url() ); exit;
exit; } else {
add_action( 'login_footer', array( $this, 'remove_login_form' ), 99 );
}
} }
// login button is appended to existing messages in case of error if ( isset( $_GET['login-error'] ) ) {
if ( $settings->login_type == 'button' ) { $message .= $this->make_error_output( $_GET['login-error'], $_GET['message'] );
$message .= $this->make_login_button();
} }
// login button is appended to existing messages in case of error
$message .= $this->make_login_button();
return $message; return $message;
} }
@ -122,4 +125,19 @@ class OpenID_Connect_Generic_Login_Form {
<?php <?php
return ob_get_clean(); return ob_get_clean();
} }
/*
* Removes the login form from the HTML DOM
*/
function remove_login_form() {
?>
<script type="text/javascript">
(function() {
var loginForm = document.getElementById("user_login").form;
var parent = loginForm.parentNode;
parent.removeChild(loginForm);
})();
</script>
<?php
}
} }

Loading…
Cancel
Save