diff options
author | Tomás Touceda <chiiph@leap.se> | 2013-08-05 11:28:36 -0300 |
---|---|---|
committer | Tomás Touceda <chiiph@leap.se> | 2013-08-05 12:20:03 -0300 |
commit | e02ed2ea8ebaeca4db9a04dc1c3d70d06d20f49f (patch) | |
tree | 0ac35d7265ac0fcc4b07aef2fac83554697f73a7 | |
parent | d2d13cf61adf51895d45556ab0b08115ea2eeb1c (diff) |
Validate the username at login against a regexp
-rw-r--r-- | changes/bug_regex_username | 2 | ||||
-rw-r--r-- | src/leap/gui/login.py | 8 |
2 files changed, 9 insertions, 1 deletions
diff --git a/changes/bug_regex_username b/changes/bug_regex_username new file mode 100644 index 00000000..9de9f2d1 --- /dev/null +++ b/changes/bug_regex_username @@ -0,0 +1,2 @@ + o Validate the username in the login form against the same regexp as + the wizard registration form. Fixes #3214.
\ No newline at end of file diff --git a/src/leap/gui/login.py b/src/leap/gui/login.py index 3eb1fe39..3c994597 100644 --- a/src/leap/gui/login.py +++ b/src/leap/gui/login.py @@ -44,6 +44,8 @@ class LoginWidget(QtGui.QWidget): MAX_STATUS_WIDTH = 40 + BARE_USERNAME_REGEX = r"^[A-Za-z\d_]+$" + def __init__(self, settings, parent=None): """ Constructs the LoginWidget. @@ -77,6 +79,10 @@ class LoginWidget(QtGui.QWidget): self.ui.btnCreateAccount.clicked.connect( self.show_wizard) + username_re = QtCore.QRegExp(self.BARE_USERNAME_REGEX) + self.ui.lnUser.setValidator( + QtGui.QRegExpValidator(username_re, self)) + def _remember_state_changed(self, state): """ Saves the remember state in the LeapSettings @@ -146,7 +152,7 @@ class LoginWidget(QtGui.QWidget): def get_user(self): """ - Returns the user that appears in the widget + Returns the user that appears in the widget. :rtype: str """ |