1/* globals console, jQuery, Cookies, wpAuth0LockGlobal, wpAuth0LockGlobalFields, Auth0Lock, Auth0LockPasswordless, auth0 */ 2jQuery(document).ready(function ($) { 3 'use strict'; 4 5 var opts = wpAuth0LockGlobal; 6 var loginForm = $( '#' + opts.loginFormId ); 7 8 // Missing critical Auth0 settings. 9 if ( ! opts.ready ) { 10 resetWpLoginForm(); 11 console.error( opts.i18n.notReadyText ); 12 return; 13 } 14 15 // Missing the Lock container. 16 if ( ! loginForm.length ) { 17 resetWpLoginForm(); 18 console.error( opts.i18n.cannotFindNodeText + '"' + opts.loginFormId + '"' ); 19 return; 20 } 21 22 // Set state and nonce cookies to verify during callback. 23 setStateCookie(opts.settings.auth.params.state); 24 if ( opts.settings.auth.params.nonce ) { 25 setNonceCookie(opts.settings.auth.params.nonce); 26 } 27 28 // Look for additional fields to display. 29 if ( typeof wpAuth0LockGlobalFields === 'object' ) { 30 opts.settings.additionalSignUpFields = wpAuth0LockGlobalFields; 31 } 32 33 // Set Lock to standard or Passwordless. 34 var Lock = opts.usePasswordless ? 35 new Auth0LockPasswordless( opts.clientId, opts.domain, opts.settings ) : 36 new Auth0Lock( opts.clientId, opts.domain, opts.settings ); 37 38 // Check if we're showing as a modal (used in shortcodes and widgets). 39 if ( opts.showAsModal ) { 40 $( '<button>' ) 41 .text( opts.i18n.modalButtonText ) 42 .attr( 'id', 'a0LoginButton' ) 43 .insertAfter( loginForm ) 44 .click(function () { Lock.show(); }); 45 } else { 46 Lock.show(); 47 } 48 49 /** 50 * Set the state cookie for verification during callback. 51 * 52 * @param val string - Value for the state cookie. 53 */ 54 function setStateCookie(val) { 55 Cookies.set( opts.stateCookieName, val ); 56 } 57 58 /** 59 * Set the nonce cookie for verification during callback. 60 * 61 * @param val string - Value for the nonce cookie. 62 */ 63 function setNonceCookie(val) { 64 Cookies.set( opts.nonceCookieName, val ); 65 } 66 67 /** 68 * Show the WordPress login form. 69 */ 70 function resetWpLoginForm() { 71 $( '#form-signin-wrapper' ).hide(); 72 $( '#loginform' ).show(); 73 $( '#login' ).find( 'h1' ).show(); 74 } 75});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.