diff options
author | Tomás Touceda <chiiph@leap.se> | 2014-09-26 10:15:06 -0300 |
---|---|---|
committer | Tomás Touceda <chiiph@leap.se> | 2014-09-26 10:15:06 -0300 |
commit | 6f7177f3ca359f8c3e74d094b0dcd0f9239fb069 (patch) | |
tree | f04b0eb5c4665a129c5c49719b2da65d325b111f /src/leap/bitmask/util/credentials.py | |
parent | e8c028f3eb6cd0681f039c456dc1ac45c98d598f (diff) | |
parent | 0db3d5a4aecc0a3c271b92c6187922c50d46df0a (diff) |
Diffstat (limited to 'src/leap/bitmask/util/credentials.py')
-rw-r--r-- | src/leap/bitmask/util/credentials.py | 24 |
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 |