summaryrefslogtreecommitdiff
path: root/src/leap/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/leap/gui')
-rw-r--r--src/leap/gui/firstrun/__init__.py6
-rw-r--r--src/leap/gui/firstrun/providerselect.py (renamed from src/leap/gui/firstrun/selectprovider.py)32
-rw-r--r--src/leap/gui/firstrun/register.py95
-rw-r--r--src/leap/gui/firstrun/regvalidation.py140
-rwxr-xr-xsrc/leap/gui/firstrun/wizard.py4
5 files changed, 176 insertions, 101 deletions
diff --git a/src/leap/gui/firstrun/__init__.py b/src/leap/gui/firstrun/__init__.py
index bf8d0df9..477e7269 100644
--- a/src/leap/gui/firstrun/__init__.py
+++ b/src/leap/gui/firstrun/__init__.py
@@ -8,9 +8,10 @@ import last
import login
import mixins
import providerinfo
+import providerselect
import providersetup
import register
-import selectprovider
+import regvalidation
__all__ = [
'connect',
@@ -19,6 +20,7 @@ __all__ = [
'login',
'mixins',
'providerinfo',
+ 'providerselect',
'providersetup',
'register',
- 'selectprovider']
+ 'regvalidation']
diff --git a/src/leap/gui/firstrun/selectprovider.py b/src/leap/gui/firstrun/providerselect.py
index e95a4af2..c282e3ab 100644
--- a/src/leap/gui/firstrun/selectprovider.py
+++ b/src/leap/gui/firstrun/providerselect.py
@@ -54,7 +54,7 @@ class SelectProviderPage(QtGui.QWizardPage):
#providercombo.addItem(provider)
#providerNameSelect = providercombo
- self.registerField('provider_domain*', self.providerNameEdit)
+ self.registerField("provider_domain*", self.providerNameEdit)
#self.registerField('provider_name_index', providerNameSelect)
validationMsg = QtGui.QLabel("")
@@ -78,6 +78,8 @@ class SelectProviderPage(QtGui.QWizardPage):
self.trustProviderCertCheckBox.stateChanged.connect(
self.onTrustCheckChanged)
+ self.providerNameEdit.textChanged.connect(
+ self.onProviderChanged)
layout = QtGui.QGridLayout()
layout.addWidget(validationMsg, 0, 2)
@@ -114,14 +116,17 @@ class SelectProviderPage(QtGui.QWizardPage):
# trigger signal to redraw next button
self.completeChanged.emit()
+ def onProviderChanged(self, text):
+ self.completeChanged.emit()
+
def reset_validation_status(self):
"""
empty the validation msg
"""
self.validationMsg.setText('')
- def set_validation_status(self, status):
- self.validationMsg.setText(status)
+ #def set_validation_status(selF, STATUS):
+ #self.validationMsg.setText(status)
def add_cert_info(self, certinfo):
self.certWarning.setText(
@@ -134,11 +139,16 @@ class SelectProviderPage(QtGui.QWizardPage):
# pagewizard methods
def isComplete(self):
- if not self.did_cert_check:
- return True
- if self.is_insecure_cert_trusted():
- return True
- return False
+ provider = self.providerNameEdit.text()
+
+ if not provider:
+ return False
+ else:
+ if self.is_insecure_cert_trusted():
+ return True
+ if not self.did_cert_check:
+ return True
+ return False
def populateErrors(self):
# XXX could move this to ValidationMixin
@@ -164,12 +174,6 @@ class SelectProviderPage(QtGui.QWizardPage):
self.validationMsg.setText('')
self.certinfoGroup.hide()
- def validatePage(self):
- """
- we are doing validation in next page
- """
- return True
-
def nextId(self):
wizard = self.wizard()
if not wizard:
diff --git a/src/leap/gui/firstrun/register.py b/src/leap/gui/firstrun/register.py
index b169f45b..d7e8db0e 100644
--- a/src/leap/gui/firstrun/register.py
+++ b/src/leap/gui/firstrun/register.py
@@ -1,16 +1,12 @@
"""
Register User Page, used in First Run Wizard
"""
-import json
import logging
-import socket
-import requests
from PyQt4 import QtCore
from PyQt4 import QtGui
-from leap.base import auth
from leap.gui.firstrun.mixins import UserFormMixIn
logger = logging.getLogger(__name__)
@@ -20,9 +16,11 @@ from leap.gui.styles import ErrorLabelStyleSheet
class RegisterUserPage(QtGui.QWizardPage, UserFormMixIn):
+
setSigningUpStatus = QtCore.pyqtSignal([])
def __init__(self, parent=None):
+
super(RegisterUserPage, self).__init__(parent)
# bind wizard page signals
@@ -105,17 +103,16 @@ class RegisterUserPage(QtGui.QWizardPage, UserFormMixIn):
def validatePage(self):
"""
- validation
- we initialize the srp protocol register
- and try to register user. if error
- returned we write validation error msg
- above the form.
+ we only pre-validate here password weakness
+ stuff, or any other client side validation
+ that we think of.
+ real server validation is made on next page,
+ and if any errors are thrown there we come back
+ and re-display the validation label.
"""
- wizard = self.wizard()
-
self.setSigningUpStatus.emit()
- username = self.userNameLineEdit.text()
+ #username = self.userNameLineEdit.text()
password = self.userPasswordLineEdit.text()
password2 = self.userPassword2LineEdit.text()
@@ -136,80 +133,10 @@ class RegisterUserPage(QtGui.QWizardPage, UserFormMixIn):
self.set_validation_status('Password too obvious.')
return False
- domain = self.field('provider_domain')
-
- if wizard and wizard.debug_server:
- # We're debugging
- dbgsrv = wizard.debug_server
- schema = dbgsrv.scheme
- netloc = dbgsrv.netloc
- port = None
- netloc_split = netloc.split(':')
- if len(netloc_split) > 1:
- provider, port = netloc_split
- else:
- provider = netloc
-
- signup = auth.LeapSRPRegister(
- scheme=schema,
- provider=provider,
- port=port)
-
- else:
- # this is the real thing
- signup = auth.LeapSRPRegister(
- # XXX FIXME FIXME FIXME FIXME
- # XXX FIXME 0 Force HTTPS !!!
- # XXX FIXME FIXME FIXME FIXME
- #schema="https",
- schema="http",
- provider=domain)
- try:
- ok, req = signup.register_user(username, password)
- except socket.timeout:
- self.set_validation_status(
- "Error connecting to provider (timeout)")
- return False
-
- except requests.exceptions.ConnectionError as exc:
- logger.error(exc)
- self.set_validation_status(
- "Error connecting to provider "
- "(connection error)")
- return False
-
- if ok:
- return True
-
- # something went wrong.
- # not registered, let's catch what.
- # get timeout
- # ...
- if req.status_code == 500:
- self.set_validation_status(
- "Error during registration (500)")
- return False
-
- if req.status_code == 404:
- self.set_validation_status(
- "Error during registration (404)")
- return False
-
- validation_msgs = json.loads(req.content)
- logger.debug('validation errors: %s' % validation_msgs)
- errors = validation_msgs.get('errors', None)
- if errors and errors.get('login', None):
- # XXX this sometimes catch the blank username
- # but we're not allowing that (soon)
- self.set_validation_status(
- 'Username not available.')
- else:
- self.set_validation_status(
- "Error during sign up")
- return False
+ return True
def nextId(self):
wizard = self.wizard()
if not wizard:
return
- return wizard.get_page_index('connecting')
+ return wizard.get_page_index('signupvalidation')
diff --git a/src/leap/gui/firstrun/regvalidation.py b/src/leap/gui/firstrun/regvalidation.py
new file mode 100644
index 00000000..42b9ccd5
--- /dev/null
+++ b/src/leap/gui/firstrun/regvalidation.py
@@ -0,0 +1,140 @@
+"""
+Provider Setup Validation Page,
+used if First Run Wizard
+"""
+import logging
+import json
+import socket
+import time
+
+from PyQt4 import QtGui
+
+import requests
+
+from leap.gui.progress import ValidationPage
+
+from leap.base import auth
+from leap.gui.constants import APP_LOGO
+
+logger = logging.getLogger(__name__)
+
+
+class RegisterUserValidationPage(ValidationPage):
+
+ def __init__(self, parent=None):
+
+ super(RegisterUserValidationPage, self).__init__(parent)
+ self.setTitle("User Creation")
+ self.setSubTitle(
+ "Registering account with provider.")
+
+ self.setPixmap(
+ QtGui.QWizard.LogoPixmap,
+ QtGui.QPixmap(APP_LOGO))
+
+ def _do_checks(self, update_signal=None):
+ """
+ executes actual checks in a separate thread
+
+ we initialize the srp protocol register
+ and try to register user.
+ """
+ wizard = self.wizard()
+ domain = self.field('provider_domain')
+ username = self.field('userName')
+ password = self.field('userPassword')
+
+ update_signal.emit("head_sentinel")
+ update_signal.emit("registering with provider", 40)
+ time.sleep(4)
+
+ if wizard and wizard.debug_server:
+ # We're debugging
+ dbgsrv = wizard.debug_server
+ schema = dbgsrv.scheme
+ netloc = dbgsrv.netloc
+ port = None
+ netloc_split = netloc.split(':')
+ if len(netloc_split) > 1:
+ provider, port = netloc_split
+ else:
+ provider = netloc
+
+ signup = auth.LeapSRPRegister(
+ scheme=schema,
+ provider=provider,
+ port=port)
+
+ else:
+ # this is the real thing
+ signup = auth.LeapSRPRegister(
+ # XXX FIXME FIXME FIXME FIXME
+ # XXX FIXME 0 Force HTTPS !!!
+ # XXX FIXME FIXME FIXME FIXME
+ #schema="https",
+ schema="http",
+ provider=domain)
+ try:
+ ok, req = signup.register_user(username, password)
+ except socket.timeout:
+ self.set_validation_status(
+ "Error connecting to provider (timeout)")
+ return False
+
+ except requests.exceptions.ConnectionError as exc:
+ logger.error(exc)
+ self.set_validation_status(
+ "Error connecting to provider "
+ "(connection error)")
+ return False
+
+ if ok:
+ return True
+
+ # something went wrong.
+ # not registered, let's catch what.
+ # get timeout
+ # ...
+ if req.status_code == 500:
+ self.set_validation_status(
+ "Error during registration (500)")
+ return False
+
+ if req.status_code == 404:
+ self.set_validation_status(
+ "Error during registration (404)")
+ return False
+
+ validation_msgs = json.loads(req.content)
+ logger.debug('validation errors: %s' % validation_msgs)
+ errors = validation_msgs.get('errors', None)
+ if errors and errors.get('login', None):
+ # XXX this sometimes catch the blank username
+ # but we're not allowing that (soon)
+ self.set_validation_status(
+ 'Username not available.')
+ else:
+ self.set_validation_status(
+ "Error during sign up")
+ return False
+
+ def _do_validation(self):
+ """
+ called after _do_checks has finished
+ (connected to checker thread finished signal)
+ """
+ wizard = self.wizard()
+ if self.errors:
+ print 'going back with errors'
+ wizard.set_validation_error(
+ 'signup', 'that name is taken')
+ self.go_back()
+ else:
+ print 'going next'
+ self.go_next()
+
+ def nextId(self):
+ wizard = self.wizard()
+ if not wizard:
+ return
+ return wizard.get_page_index('connecting')
diff --git a/src/leap/gui/firstrun/wizard.py b/src/leap/gui/firstrun/wizard.py
index fb601714..7a3d6973 100755
--- a/src/leap/gui/firstrun/wizard.py
+++ b/src/leap/gui/firstrun/wizard.py
@@ -109,12 +109,14 @@ class FirstRunWizard(QtGui.QWizard):
pages_dict = OrderedDict((
('intro', firstrun.intro.IntroPage),
('providerselection',
- firstrun.selectprovider.SelectProviderPage),
+ firstrun.providerselect.SelectProviderPage),
('login', firstrun.login.LogInPage),
('providerinfo', firstrun.providerinfo.ProviderInfoPage),
('providersetupvalidation',
firstrun.providersetup.ProviderSetupValidationPage),
('signup', firstrun.register.RegisterUserPage),
+ ('signupvalidation',
+ firstrun.regvalidation.RegisterUserValidationPage),
('connecting', firstrun.connect.ConnectingPage),
('lastpage', firstrun.last.LastPage)
))