summaryrefslogtreecommitdiff
path: root/src/leap/gui/firstrun/register.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/leap/gui/firstrun/register.py')
-rw-r--r--src/leap/gui/firstrun/register.py95
1 files changed, 11 insertions, 84 deletions
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')