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

@ -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) {