fix: signup password hint validation (#10454)
Co-authored-by: Udit Takkar <[email protected]>
This commit is contained in:
1 parent
b285f27d00
commit
79f092673a
6 files changed
+49
-58
No files matched your search
@@ -10,15 +10,11 @@ export function isPasswordValid(password: string, breakdown?: boolean, strict?:
|
||||
num = false, // At least one number
|
||||
min = false, // Eight characters, or fifteen in strict mode.
|
||||
admin_min = false;
|
||||
if (password.length > 7 && (!strict || password.length > 14)) min = true;
|
||||
if (password.length >= 7 && (!strict || password.length > 14)) min = true;
|
||||
if (strict && password.length > 14) admin_min = true;
|
||||
for (let i = 0; i < password.length; i++) {
|
||||
if (!isNaN(parseInt(password[i]))) num = true;
|
||||
else {
|
||||
if (password[i] === password[i].toUpperCase()) cap = true;
|
||||
if (password[i] === password[i].toLowerCase()) low = true;
|
||||
}
|
||||
}
|
||||
if (password.match(/\d/)) num = true;
|
||||
if (password.match(/[a-z]/)) low = true;
|
||||
if (password.match(/[A-Z]/)) cap = true;
|
||||
|
||||
if (!breakdown) return cap && low && num && min && (strict ? admin_min : true);
|
||||
|
||||
|
||||
Reference in new issue
Block a user