updated plugin WP-WebAuthn version 1.3.1

This commit is contained in:
2023-10-22 22:21:36 +00:00
committed by Gitium
parent 959829cf69
commit c7746517a0
931 changed files with 5408 additions and 1937 deletions

View File

@ -82,4 +82,4 @@ jQuery('#clear_log').click((e) => {
updateLog();
}
})
})
})

View File

@ -1,7 +1,10 @@
'use strict';
document.addEventListener('DOMContentLoaded', () => {
if (document.querySelectorAll('#lostpasswordform, #registerform, .admin-email-confirm-form').length > 0) {
if (document.querySelectorAll('#lostpasswordform, #registerform, .admin-email-confirm-form, #resetpassform').length > 0) {
return;
}
if (document.getElementById('loginform') === null || document.getElementById('loginform').getAttribute('name') !== 'loginform') {
return;
}
window.onload = () => {
@ -53,7 +56,7 @@ document.addEventListener('DOMContentLoaded', () => {
wwa_dom('user_login', (dom) => { dom.focus() }, 'id');
wwa_dom('wp-submit', (dom) => { dom.disabled = true }, 'id');
}
if (document.querySelectorAll('#lostpasswordform, #registerform').length > 0) {
if (document.querySelectorAll('#lostpasswordform, #registerform, .admin-email-confirm-form, #resetpassform').length > 0) {
return;
}
wwa_dom('user_pass', (dom) => { dom.disabled = false }, 'id');
@ -61,9 +64,9 @@ document.addEventListener('DOMContentLoaded', () => {
if (dom.length > 0) {
if (dom[0].getElementsByTagName('input').length > 0) {
// WordPress 5.2-
dom[0].innerHTML = `<span id="wwa-username-label">${php_vars.i18n_9}</span>${dom[0].innerHTML.split('<br>')[1]}`;
dom[0].innerHTML = `<span id="wwa-username-label">${php_vars.email_login === 'true' ? php_vars.i18n_10 : php_vars.i18n_9}</span>${dom[0].innerHTML.split('<br>')[1]}`;
} else {
dom[0].innerText = php_vars.i18n_9;
dom[0].innerText = php_vars.email_login === 'true' ? php_vars.i18n_10 : php_vars.i18n_9;
}
}
}

View File

@ -71,9 +71,26 @@ const wwa_dom = (selector, callback = () => { }, method = 'query') => {
let wwaSupported = true;
document.addEventListener('DOMContentLoaded', () => {
if (document.querySelectorAll('#lostpasswordform, #registerform, .admin-email-confirm-form').length > 0) {
if (document.querySelector('p#nav') && php_vars.password_reset !== 'false') {
const placeholder = document.getElementById('wwa-lost-password-link-placeholder');
if (placeholder) {
const previous = placeholder.previousSibling;
const next = placeholder.nextElementSibling;
if (previous && previous.nodeType === Node.TEXT_NODE && previous.data.trim() === php_vars.separator.trim()) {
previous.remove();
} else if (next && next.nodeType === Node.TEXT_NODE && next.data.trim() === php_vars.separator.trim()) {
next.remove();
}
}
placeholder.remove();
}
if (document.querySelectorAll('#lostpasswordform, #registerform, .admin-email-confirm-form, #resetpassform').length > 0) {
return;
}
if (document.getElementById('loginform') === null || document.getElementById('loginform').getAttribute('name') !== 'loginform') {
return;
}
document.addEventListener('keydown', parseKey, false);
let button_check = document.createElement('button');
button_check.id = 'wp-webauthn-check';
button_check.type = 'button';
@ -125,7 +142,7 @@ document.addEventListener('DOMContentLoaded', () => {
})
window.onresize = function () {
if (document.querySelectorAll('#lostpasswordform, #registerform').length > 0) {
if (document.querySelectorAll('#lostpasswordform, #registerform, .admin-email-confirm-form, #resetpassform').length > 0) {
return;
}
let btnWidth = document.getElementById('wp-submit').clientWidth;
@ -136,11 +153,9 @@ window.onresize = function () {
}
}
document.addEventListener('keydown', parseKey, false);
function parseKey(event) {
if (wwaSupported && document.getElementById('wp-webauthn-check').style.display === 'block') {
if (event.keyCode === 13) {
if (event.keyCode === 13) {
if (wwaSupported && document.getElementById('wp-webauthn-check').style.display === 'block') {
event.preventDefault();
wwa_dom('wp-webauthn-check', (dom) => { dom.click() }, 'id');
}
@ -159,7 +174,6 @@ function base64url2base64(input) {
return input;
}
function arrayToBase64String(a) {
return btoa(String.fromCharCode(...a));
}
@ -179,7 +193,10 @@ function getQueryString(name) {
}
function toggle() {
if (document.querySelectorAll('#lostpasswordform, #registerform').length > 0) {
if (document.querySelectorAll('#lostpasswordform, #registerform, .admin-email-confirm-form, #resetpassform').length > 0) {
return;
}
if (document.getElementById('loginform') === null || document.getElementById('loginform').getAttribute('name') !== 'loginform') {
return;
}
if (wwaSupported) {
@ -229,9 +246,9 @@ function toggle() {
if (inputDom.length > 0) {
if (document.getElementById('wwa-username-label')) {
// WordPress 5.2-
document.getElementById('wwa-username-label').innerText = php_vars.i18n_9;
document.getElementById('wwa-username-label').innerText = php_vars.email_login === 'true' ? php_vars.i18n_10 : php_vars.i18n_9;
} else {
inputDom[0].innerText = php_vars.i18n_9;
inputDom[0].innerText = php_vars.email_login === 'true' ? php_vars.i18n_10 : php_vars.i18n_9;
}
}
}
@ -255,7 +272,7 @@ function wwa_shake(id, a, d) {
}
function check() {
if (document.querySelectorAll('#lostpasswordform, #registerform').length > 0) {
if (document.querySelectorAll('#lostpasswordform, #registerform, .admin-email-confirm-form, #resetpassform').length > 0) {
return;
}
if (wwaSupported) {

View File

@ -12,6 +12,9 @@ window.addEventListener('load', () => {
if (document.getElementById('wp-webauthn-error-container')) {
document.getElementById('wp-webauthn-error-container').insertBefore(document.getElementById('wp-webauthn-error'), null);
}
if (document.getElementById('wp-webauthn-message-container')) {
document.getElementById('wp-webauthn-message-container').insertBefore(document.getElementById('wp-webauthn-message'), null);
}
})
// Update authenticator list
@ -296,6 +299,7 @@ jQuery('#wwa-bind').click((e) => {
// Test WebAuthn
jQuery('#wwa-test, #wwa-test_usernameless').click((e) => {
e.preventDefault();
jQuery('#wwa-test, #wwa-test_usernameless').attr('disabled', 'disabled');
let button_id = e.target.id;
let usernameless = 'false';