Improved password strength meter

This commit is contained in:
djmaze 2021-03-05 09:43:46 +01:00
parent c538ebe174
commit addaede0df
2 changed files with 10 additions and 18 deletions

View file

@ -10,15 +10,12 @@
getPassStrength = v => {
let m,
i = v.length,
s = i?1:0,
max = Math.min(100, i * 8),
s = 0,
c = 0,
ii;
while (i--) {
if (v[i] != v[i+1]) {
++s;
} else {
s -= 0.5;
}
s += (v[i] != v[i+1] ? 1 : -0.5);
}
for (i = 0; i < 4; ++i) {
m = v.match(pw_re[i]);
@ -31,8 +28,7 @@
}
}
}
s = (s / 3 * c);
return Math.max(0, Math.min(100, s * 5));
return Math.max(0, Math.min(max, s * c * 1.5));
};
class ChangePasswordUserSettings