1jQuery(function ($) { 2 var login_nonce = ur_login_params.ur_login_form_save_nonce; 3 var update_login_nonce = function() { 4 $.ajax({ 5 url: user_registration_params.ajax_url, 6 data: { 7 action: 'user_registration_get_recent_nonce', 8 nonce_for: 'login' 9 }, 10 type: "POST", 11 async: true, 12 complete: function (ajax_response) { 13 var response = JSON.parse(ajax_response.responseText); 14 if(response.success) { 15 login_nonce = response.data; 16 } 17 } 18 }); 19 }; 20 update_login_nonce(); 21 $(".ur-frontend-form") 22 .find("form.login") 23 .each(function () { 24 var $ur_login_ajax_form = $(this); 25 26 $ur_login_ajax_form 27 .find("#user_registration_ajax_login_submit") 28 .on("click", function (e) { 29 e.preventDefault(); 30 var $this = $(this); 31 var username = $this 32 .closest("form") 33 .find('input[name="username"]') 34 .val(); 35 var password = $this 36 .closest("form") 37 .find('input[name="password"]') 38 .val(); 39 var rememberme = $this 40 .closest("form") 41 .find('input[name="rememberme"]') 42 .val(), 43 redirect_url = $this 44 .closest("form") 45 .find('input[name="redirect"]') 46 .val(); 47 if ("hCaptcha" === ur_login_params.recaptcha_type) { 48 var CaptchaResponse = $this 49 .closest("form") 50 .find('[name="h-captcha-response"]') 51 .val(); 52 } else if ( 53 "cloudflare" === ur_login_params.recaptcha_type 54 ) { 55 var CaptchaResponse = $this 56 .closest("form") 57 .find('[name="cf-turnstile-response"]') 58 .val(); 59 } else { 60 var CaptchaResponse = $this 61 .closest("form") 62 .find('[name="g-recaptcha-response"]') 63 .val(); 64 } 65 66 var url = 67 ur_login_params.ajax_url + 68 "?action=user_registration_ajax_login_submit&security=" + 69 login_nonce; 70 71 if (window.location.href.indexOf("pl=true") > -1) { 72 // "pl=true" is present in the URL. 73 url += "&pl=true"; 74 } 75 76 $this 77 .closest("form") 78 .find(".ur-submit-button span") 79 .addClass("ur-spinner"); 80 81 var data = { 82 username: username, 83 password: password, 84 CaptchaResponse: CaptchaResponse, 85 redirect: redirect_url, 86 previous_page: document.referrer ? document.referrer : '' 87 }; 88 89 if ( 90 $this 91 .closest("form") 92 .find('input[name="rememberme"]') 93 .is(":checked") 94 ) { 95 data.rememberme = rememberme; 96 } 97 98 $.ajax({ 99 type: "POST", 100 url: url, 101 data: data, 102 success: function (res) { 103 $this 104 .closest("form") 105 .find(".ur-submit-button span") 106 .removeClass("ur-spinner"); 107 108 // custom error message 109 if (res.success == false) { 110 $(document).trigger( 111 "user_registration_after_login_failed", 112 [$this] 113 ); 114 115 $this 116 .closest("#user-registration") 117 .find(".user-registration-error") 118 .remove(); 119 120 $this 121 .closest("") 122 .find(".user-registration-message") 123 .remove(); 124 125 var $errorUl = $('<ul class="user-registration-error"></ul>'); 126 $errorUl.html(res.data.message); 127 $this 128 .closest(".ur-frontend-form") 129 .prepend($errorUl); 130 } else { 131 if (res.data.status) { 132 $this 133 .closest("#user-registration") 134 .find(".user-registration-error") 135 .remove(); 136 137 $this 138 .closest("#user-registration") 139 .find(".user-registration-message") 140 .remove(); 141 142 var $msgUl = $('<ul class="user-registration-message"></ul>'); 143 $msgUl.html(res.data.message); 144 $this 145 .closest(".ur-frontend-form") 146 .prepend($msgUl); 147 148 $this 149 .closest("#user-registration") 150 .find("input#username") 151 .val(""); 152 } else { 153 window.location.href = res.data.message; 154 } 155 } 156 } 157 }).fail(function () { 158 $this 159 .closest("#user-registration") 160 .find(".user-registration-error") 161 .remove(); 162 $this 163 .closest("form") 164 .find(".ur-submit-button span") 165 .removeClass("ur-spinner"); 166 167 // Add a hidden input to ensure $_POST['login'] is present 168 var loginValue = 'Login', 169 $hiddenLogin = $('<input>', { 170 type: 'hidden', 171 name: 'login', 172 value: loginValue 173 }), 174 $resubmitted = $('<input>', { 175 type: 'hidden', 176 name: 'resubmitted', 177 value: true 178 }); 179 $ur_login_ajax_form.append($hiddenLogin); 180 $ur_login_ajax_form.append($resubmitted); 181 $ur_login_ajax_form[0].submit(); 182 }); 183 }); 184 }); 185 186});
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.