-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Passwordless (PWL) was not working with new tenants and used the old, separate PWL JS library. This commit updates the Lock library used to 11.5, moves and re-writes the JS used to show Lock, loads required JS in one place for widget + shortcode + wp-login, and revises state handling to work better for the shortcode and widget.
- Loading branch information
1 parent
9724203
commit 76ad48f
Showing
9 changed files
with
132 additions
and
249 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* globals jQuery, console, alert, wpAuth0PwlGlobal, Auth0LockPasswordless */ | ||
jQuery(document).ready(function ($) { | ||
|
||
var formWrapper = $( '#form-signin-wrapper' ); | ||
var modalButton = $( '#a0LoginButton' ); | ||
|
||
// Missing critical Auth0 settings | ||
if ( ! wpAuth0PwlGlobal.lock.ready ) { | ||
formWrapper.hide(); | ||
$( '#loginform' ).show(); | ||
$( '#login' ).find( 'h1' ).show(); | ||
return; | ||
} | ||
|
||
// General Lock options pulled from the settings | ||
var options = wpAuth0PwlGlobal.lock.options; | ||
|
||
// Extra options are set in the shortcode and widget | ||
var extraOptions = formWrapper.attr( 'data-auth0-opts' ); | ||
|
||
if ( extraOptions ) { | ||
try { | ||
extraOptions = JSON.parse( extraOptions ); | ||
$.extend( options, extraOptions ); | ||
} catch ( err ) { | ||
// TODO: better handling | ||
console.log( err.message ); | ||
} | ||
} | ||
|
||
var Lock = new Auth0LockPasswordless( | ||
wpAuth0PwlGlobal.lock.clientId, | ||
wpAuth0PwlGlobal.lock.domain, | ||
options | ||
); | ||
|
||
if ( extraOptions.show_as_modal ) { | ||
modalButton.click( Lock.show ); | ||
} else { | ||
Lock.show(); | ||
} | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
$auth0_options = WP_Auth0_Options::Instance(); | ||
?> | ||
|
||
<div id="form-signin-wrapper" class="auth0-login" data-auth0-opts="<?php echo esc_attr( json_encode( $specialSettings ) ) ?>"> | ||
<?php include 'error-msg.php'; ?> | ||
<div class="form-signin"> | ||
<div id="auth0-login-form"></div> | ||
<?php if ( ! empty( $specialSettings['show_as_modal'] ) ) : ?> | ||
<button id="a0LoginButton" ><?php | ||
echo ! empty ( $specialSettings['modal_trigger_name'] ) | ||
? sanitize_text_field($specialSettings['modal_trigger_name'] ) | ||
: __( 'Login', 'wp-auth0' ) | ||
?></button> | ||
<?php endif; ?> | ||
|
||
<?php if ( $auth0_options->get( 'wordpress_login_enabled' ) && function_exists( 'login_header' ) ) { ?> | ||
<div id="extra-options"> | ||
<a href="<?php echo wp_login_url() ?>?wle"> | ||
<?php _e( 'Login with WordPress username', 'wp-auth0' ) ?> | ||
</a> | ||
</div> | ||
<?php } ?> | ||
|
||
</div> | ||
</div> | ||
|
||
<style type="text/css"> | ||
<?php echo apply_filters( 'auth0_login_css', '' ); ?> | ||
<?php echo $auth0_options->get( 'custom_css' ); ?> | ||
</style> | ||
|
||
<?php if ( $custom_js = $auth0_options->get( 'custom_js' ) ) : ?> | ||
<script type="text/javascript"> | ||
document.addEventListener("DOMContentLoaded", function() { | ||
<?php echo $custom_js; ?> | ||
}); | ||
</script> | ||
<?php endif; ?> |
Oops, something went wrong.