diff MoinMoin/config/multiconfig.py @ 4336:4f3d0b92d1c9

add i18n to the password checker result messages, add request param
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Thu, 25 Sep 2008 18:31:24 +0200
parents e88baf535b48
children 817d99d715fe
line wrap: on
line diff
--- a/MoinMoin/config/multiconfig.py	Tue Sep 23 00:44:45 2008 +0200
+++ b/MoinMoin/config/multiconfig.py	Thu Sep 25 18:31:24 2008 +0200
@@ -638,7 +638,7 @@
     # the options dictionary.
 
 
-def _default_password_checker(request, username, password):
+def _default_password_checker(cfg, request, username, password):
     """ Check if a password is secure enough.
         We use a built-in check to get rid of the worst passwords.
 
@@ -650,18 +650,19 @@
         @return: None if there is no problem with the password,
                  some string with an error msg, if the password is problematic.
     """
+    _ = request.getText
     try:
         # in any case, do a very simple built-in check to avoid the worst passwords
         if len(password) < 6:
-            raise ValueError("Password too short.")
+            raise ValueError(_("Password is too short."))
         if len(set(password)) < 4:
-            raise ValueError("Password has not enough different characters.")
+            raise ValueError(_("Password has not enough different characters."))
 
         username_lower = username.lower()
         password_lower = password.lower()
         if username in password or password in username or \
            username_lower in password_lower or password_lower in username_lower:
-            raise ValueError("Password too easy (containment).")
+            raise ValueError(_("Password is too easy (password contains name or name contains password)."))
 
         keyboards = (ur"`1234567890-=qwertyuiop[]\asdfghjkl;'zxcvbnm,./", # US kbd
                      ur"^1234567890ß´qwertzuiopü+asdfghjklöä#yxcvbnm,.-", # german kbd
@@ -670,10 +671,10 @@
             rev_kbd = kbd[::-1]
             if password in kbd or password in rev_kbd or \
                password_lower in kbd or password_lower in rev_kbd:
-                raise ValueError("Password too easy (kbd sequence)")
+                raise ValueError(_("Password is too easy (keyboard sequence)."))
         return None
     except ValueError, err:
-        return str(err)
+        return unicode(err)
 
 
 class DefaultExpression(object):