Password strength test improvements.
authorFlorent Bruneau <florent.bruneau@polytechnique.org>
Sun, 4 May 2008 11:25:07 +0000 (13:25 +0200)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Sun, 4 May 2008 11:25:07 +0000 (13:25 +0200)
Signed-off-by: Florent Bruneau <florent.bruneau@polytechnique.org>
htdocs/javascript/xorg.js

index c25725f..3506e52 100644 (file)
@@ -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) {