* rather let webcit rate password than layer 9
authorWilfried Göesgens <willi@citadel.org>
Mon, 23 Jun 2008 22:11:46 +0000 (22:11 +0000)
committerWilfried Göesgens <willi@citadel.org>
Mon, 23 Jun 2008 22:11:46 +0000 (22:11 +0000)
webcit/auth.c

index 01d7bbe4e20ac45d77de0547b582339305ea2dfc..22b8eb200cd51861791392e81a60acb4a981cabe 100644 (file)
@@ -6,6 +6,7 @@
 
 #include "webcit.h"
 #include "webserver.h"
+#include <ctype.h>
 
 /*
  * Access level definitions.  This is initialized from a function rather than a
@@ -671,8 +672,43 @@ void validate(void)
                        if (a == 1)
                                wprintf("#%s<br /><H1>%s</H1>",
                                        buf, &cmd[4]);
-                       if (a == 2)
-                               wprintf("PW: %s<br />\n", buf);
+                       if (a == 2) {
+                               char *pch;
+                               int haveChar = 0;
+                               int haveNum = 0;
+                               int haveOther = 0;
+                               int count = 0;
+                               pch = buf;
+                               while (!IsEmptyStr(pch))
+                               {
+                                       if (isdigit(*pch))
+                                               haveNum = 1;
+                                       else if (isalpha(*pch))
+                                               haveChar = 1;
+                                       else
+                                               haveOther = 1;
+                                       pch ++;
+                               }
+                               count = pch - buf;
+                               if (count > 7)
+                                       count = 0;
+                               switch (count){
+                               case 0:
+                                       pch = _("verry weak");
+                                       break;
+                               case 1:
+                                       pch = _("weak");
+                                       break;
+                               case 2:
+                                       pch = _("ok");
+                                       break;
+                               case 3:
+                               default:
+                                       pch = _("strong");
+                               }
+
+                               wprintf("PW: %s<br />\n", pch);
+                       }
                        if (a == 3)
                                wprintf("%s<br />\n", buf);
                        if (a == 4)