summaryrefslogtreecommitdiff
path: root/src/leap/gui/firstrun/register.py
diff options
context:
space:
mode:
authorkali <kali@leap.se>2012-11-12 12:45:37 +0900
committerkali <kali@leap.se>2012-11-12 12:45:37 +0900
commit42ba228eecb5726506848bd08758bd1f925905cc (patch)
treef75626d9add4a6ab377f0f487858109b85b6b3cd /src/leap/gui/firstrun/register.py
parentfe16e62fa83c24d2ef379a3f9e102d336e527656 (diff)
fix prevalidation error showing in register page.
Diffstat (limited to 'src/leap/gui/firstrun/register.py')
-rw-r--r--src/leap/gui/firstrun/register.py27
1 files changed, 23 insertions, 4 deletions
diff --git a/src/leap/gui/firstrun/register.py b/src/leap/gui/firstrun/register.py
index 6d15c156..b46dd4cd 100644
--- a/src/leap/gui/firstrun/register.py
+++ b/src/leap/gui/firstrun/register.py
@@ -95,18 +95,30 @@ class RegisterUserPage(QtGui.QWizardPage, UserFormMixIn):
bad_str = getattr(self, 'bad_string', None)
cur_str = self.userNameLineEdit.text()
showerr = self.validationMsg.setText
+ prev_er = getattr(self, 'prevalidation_error', None)
+
if bad_str is None:
# first time we fall here.
# save the current bad_string value
self.bad_string = cur_str
showerr(errors)
else:
+ if prev_er:
+ showerr(prev_er)
+ return
# not the first time
if cur_str == bad_str:
showerr(errors)
else:
showerr('')
+ def cleanup_errormsg(self):
+ """
+ we reset bad_string to None
+ should be called before leaving the page
+ """
+ self.bad_string = None
+
def paintEvent(self, event):
"""
we hook our populate errors
@@ -118,6 +130,9 @@ class RegisterUserPage(QtGui.QWizardPage, UserFormMixIn):
super(RegisterUserPage, self).paintEvent(event)
self.populateErrors()
+ def set_prevalidation_error(self, error):
+ self.prevalidation_error = error
+
def validatePage(self):
"""
we only pre-validate here password weakness
@@ -137,18 +152,22 @@ class RegisterUserPage(QtGui.QWizardPage, UserFormMixIn):
# to assess strenght and avoid silly stuff.
if password != password2:
- self.set_validation_status('Password does not match.')
+ self.set_prevalidation_error('Password does not match.')
return False
if len(password) < 6:
- self.set_validation_status('Password too short.')
+ self.set_prevalidation_error('Password too short.')
return False
if password == "123456":
- # joking
- self.set_validation_status('Password too obvious.')
+ # joking, but not too much.
+ self.set_prevalidation_error('Password too obvious.')
return False
+ # some cleanup before we leave the page
+ self.cleanup_errormsg()
+
+ # go
return True
def initializePage(self):