summaryrefslogtreecommitdiff
path: root/src/leap/bitmask/util/credentials.py
diff options
context:
space:
mode:
authorelijah <elijah@riseup.net>2014-09-08 02:01:14 -0700
committerelijah <elijah@riseup.net>2014-09-19 14:23:14 -0700
commit6166ffedcae0763f3c00076c79e74847f5c80823 (patch)
treecb649abc87ed6030c20ccdb9ac95dce51b2f1ec5 /src/leap/bitmask/util/credentials.py
parent4e7c4b48b4255ceac06900fa9e65824c52e15ba7 (diff)
single pref win: moved password change UI to a separate window, opened from account page in preferences.
Diffstat (limited to 'src/leap/bitmask/util/credentials.py')
-rw-r--r--src/leap/bitmask/util/credentials.py24
1 files changed, 15 insertions, 9 deletions
diff --git a/src/leap/bitmask/util/credentials.py b/src/leap/bitmask/util/credentials.py
index 757ce10c..dfc78a09 100644
--- a/src/leap/bitmask/util/credentials.py
+++ b/src/leap/bitmask/util/credentials.py
@@ -38,7 +38,7 @@ def username_checks(username):
valid = USERNAME_VALIDATOR.validate(username, 0)
valid_username = valid[0] == QtGui.QValidator.State.Acceptable
if message is None and not valid_username:
- message = _tr("Invalid username")
+ message = _tr("That username is not allowed. Try another.")
return message is None, message
@@ -54,28 +54,34 @@ def password_checks(username, password, password2):
:param password2: second password from the registration form
:type password: str
- :returns: True and empty message if all the checks pass,
- False and an error message otherwise
- :rtype: tuple(bool, str)
+ :returns: (True, None, None) if all the checks pass,
+ (False, message, field name) otherwise
+ :rtype: tuple(bool, str, str)
"""
# translation helper
_tr = QtCore.QObject().tr
message = None
+ field = None
if message is None and password != password2:
message = _tr("Passwords don't match")
+ field = 'new_password_confirmation'
if message is None and not password:
- message = _tr("You can't use an empty password")
+ message = _tr("Password is empty")
+ field = 'new_password'
if message is None and len(password) < 8:
- message = _tr("Password too short")
+ message = _tr("Password is too short")
+ field = 'new_password'
if message is None and password in WEAK_PASSWORDS:
- message = _tr("Password too easy")
+ message = _tr("Password is too easy")
+ field = 'new_password'
if message is None and username == password:
- message = _tr("Password equal to username")
+ message = _tr("Password can't be the same as username")
+ field = 'new_password'
- return message is None, message
+ return message is None, message, field