mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2025-03-09 15:40:18 +00:00
Fixed numeric password requirement check.
This commit is contained in:
parent
d5ae0e10eb
commit
1c4e8ab607
7 changed files with 107 additions and 111 deletions
|
@ -167,14 +167,14 @@ module.exports.checkPasswordRequirements = function(password, requirements) {
|
|||
if ((requirements == null) || (requirements == '') || (typeof requirements != 'object')) return true;
|
||||
if (requirements.min) { if (password.length < requirements.min) return false; }
|
||||
if (requirements.max) { if (password.length > requirements.max) return false; }
|
||||
var num = 0, lower = 0, upper = 0, nonalpha = 0;
|
||||
var numeric = 0, lower = 0, upper = 0, nonalpha = 0;
|
||||
for (var i = 0; i < password.length; i++) {
|
||||
if (/\d/.test(password[i])) { num++; }
|
||||
if (/\d/.test(password[i])) { numeric++; }
|
||||
if (/[a-z]/.test(password[i])) { lower++; }
|
||||
if (/[A-Z]/.test(password[i])) { upper++; }
|
||||
if (/\W/.test(password[i])) { nonalpha++; }
|
||||
}
|
||||
if (requirements.num && (num < requirements.num)) return false;
|
||||
if (requirements.numeric && (numeric < requirements.numeric)) return false;
|
||||
if (requirements.lower && (lower < requirements.lower)) return false;
|
||||
if (requirements.upper && (upper < requirements.upper)) return false;
|
||||
if (requirements.nonalpha && (nonalpha < requirements.nonalpha)) return false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue