From eaa3f284c29668ea93dcf1243a4ac34f229ab2b1 Mon Sep 17 00:00:00 2001 From: Florent Bruneau Date: Sun, 4 May 2008 13:25:07 +0200 Subject: [PATCH] Password strength test improvements. Signed-off-by: Florent Bruneau --- htdocs/javascript/xorg.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) 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) { -- 2.1.4