This commit is contained in:
2024-08-30 17:36:21 +08:00
parent a3f0288c92
commit eec9d6045c
19 changed files with 332 additions and 219 deletions

View File

@@ -53,19 +53,24 @@ function isPhone(text) {
return false;
}
function verifyPassword(password, min) {
function getPasswordStrength(password) {
if (password == null || typeof password !== 'string') {
return false;
return 0;
}
if (password.length < 8) {
return false;
return 0;
}
min ??= 3;
let secure = 0;
if (/[0-9]/.test(password)) { secure++ }
if (/[a-z]/.test(password)) { secure++ }
if (/[A-Z]/.test(password)) { secure++ }
if (/[^0-9a-zA-Z]/.test(password)) { secure++ }
return secure;
}
function verifyPassword(password, min) {
min ??= 3;
const secure = getPasswordStrength(password);
return secure >= min;
}
@@ -100,6 +105,7 @@ export {
truncate,
isEmail,
isPhone,
getPasswordStrength,
verifyPassword,
domLoad
}