mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-03 06:27:02 +03:00
Issue #51
Added: visual password weakness meter Bugfix: PasswordWeaknessCheck
This commit is contained in:
parent
96ea4fdf0a
commit
a36cb17165
3 changed files with 39 additions and 2 deletions
|
|
@ -6,6 +6,35 @@
|
|||
return;
|
||||
}
|
||||
|
||||
let pw_re = [/[^0-9A-Za-z]+/g, /[0-9]+/g, /[A-Z]+/g, /[a-z]+/g],
|
||||
getPassStrength = v => {
|
||||
var m,
|
||||
i = v.length,
|
||||
s = i?1:0,
|
||||
c = 0,
|
||||
ii = 0;
|
||||
while (i--) {
|
||||
if (v[i] != v[i+1]) {
|
||||
++s;
|
||||
} else {
|
||||
s -= 0.5;
|
||||
}
|
||||
}
|
||||
for (i = 0; i < 4; ++i) {
|
||||
m = v.match(pw_re[i]);
|
||||
if (m) {
|
||||
++c;
|
||||
for (; ii < m.length; ++ii) {
|
||||
if (5 > m[ii].length) {
|
||||
++s;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
s = (s / 3 * c);
|
||||
return Math.max(0, Math.min(100, s * 5));
|
||||
};
|
||||
|
||||
class ChangePasswordUserSettings
|
||||
{
|
||||
constructor() {
|
||||
|
|
@ -68,6 +97,12 @@
|
|||
current ? this.currentPasswordError(false) : this.passwordMismatch(false);
|
||||
}
|
||||
|
||||
onBuild(dom) {
|
||||
let input = dom.querySelector('.new-password'),
|
||||
meter = dom.querySelector('.new-password-meter');
|
||||
input && meter && input.addEventListener('input',() => meter.value = getPassStrength(input.value));
|
||||
}
|
||||
|
||||
onHide() {
|
||||
this.reset(false);
|
||||
this.currentPassword('');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue