diff options
author | Ivan Alejandro <ivanalejandro0@gmail.com> | 2014-09-22 16:17:02 -0300 |
---|---|---|
committer | Ivan Alejandro <ivanalejandro0@gmail.com> | 2014-09-22 16:17:02 -0300 |
commit | c1fa3959fbffb381e067dcd619d528412e235401 (patch) | |
tree | 72662a8d2102dd782d68006d69e3b3058d8bd899 /src/leap/bitmask/util/credentials.py | |
parent | 30fe51fa5c90a5ec08491b6d3f8524838ec75ac2 (diff) | |
parent | 668a9f9aa327c3c055b9e0f641f8c33d59e1c452 (diff) |
Merge remote-tracking branch 'elijah/feature/prefui' into develop
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 |