From: Florent Bruneau Date: Sun, 4 May 2008 11:25:07 +0000 (+0200) Subject: Password strength test improvements. X-Git-Tag: core/1.0.0~211 X-Git-Url: http://git.polytechnique.org/?a=commitdiff_plain;h=eaa3f284c29668ea93dcf1243a4ac34f229ab2b1;p=platal.git Password strength test improvements. Signed-off-by: Florent Bruneau --- diff --git a/htdocs/javascript/xorg.js b/htdocs/javascript/xorg.js index c25725f..3506e52 100644 --- a/htdocs/javascript/xorg.js +++ b/htdocs/javascript/xorg.js @@ -304,20 +304,24 @@ function checkPassword(box) { var prop = 0; var pass = box.value; var types = Array(0, 0, 0, 0, 0); + var firstType = true; for (i = 0 ; i < pass.length ; ++i) { type = getType(pass.charAt(i)); if (prev != 0 && prev != type) { prop += 5; } - if (i >= 5) { - prop += 5; - } - if (types[type] == 0) { - prop += 10; + prop += i; + if (types[type] == 0 && !firstType) { + prop += 15; + } else { + firstType = false; } types[type]++; prev = type; } + if (pass.length < 6) { + prop *= 0.8; + } if (prop > 100) { prop = 100; } else if (prop < 0) {