summaryrefslogtreecommitdiff
path: root/src/leap/gui/firstrun/regvalidation.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/leap/gui/firstrun/regvalidation.py')
-rw-r--r--src/leap/gui/firstrun/regvalidation.py179
1 files changed, 59 insertions, 120 deletions
diff --git a/src/leap/gui/firstrun/regvalidation.py b/src/leap/gui/firstrun/regvalidation.py
index dbe30d3c..0e67834b 100644
--- a/src/leap/gui/firstrun/regvalidation.py
+++ b/src/leap/gui/firstrun/regvalidation.py
@@ -9,18 +9,18 @@ used in First Run Wizard
# the login branch of the wizard.
import logging
-import json
-import socket
+#import json
+#import socket
from PyQt4 import QtGui
-import requests
+#import requests
from leap.gui.progress import ValidationPage
from leap.util.web import get_https_domain_and_port
from leap.base import auth
-from leap.gui.constants import APP_LOGO, pause_for_user
+from leap.gui.constants import APP_LOGO
logger = logging.getLogger(__name__)
@@ -29,16 +29,10 @@ class RegisterUserValidationPage(ValidationPage):
def __init__(self, parent=None):
super(RegisterUserValidationPage, self).__init__(parent)
- is_signup = self.field("is_signup")
- self.is_signup = is_signup
- if is_signup:
- title = "User Creation"
- subtitle = "Registering account with provider."
- else:
- title = "Connecting..."
- # XXX uh... really?
- subtitle = "Checking connection with provider."
+ title = "Connecting..."
+ # XXX uh... really?
+ subtitle = "Checking connection with provider."
self.setTitle(title)
self.setSubTitle(subtitle)
@@ -67,7 +61,7 @@ class RegisterUserValidationPage(ValidationPage):
# Set Credentials.
# username and password are in different fields
# if they were stored in log_in or sign_up pages.
- is_signup = self.is_signup
+ is_signup = self.field("is_signup")
unamek_base = 'userName'
passwk_base = 'userPassword'
@@ -83,125 +77,58 @@ class RegisterUserValidationPage(ValidationPage):
pCertChecker = wizard.providercertchecker(
domain=full_domain)
- ###########################################
- # only if from signup
- if is_signup:
- signup = auth.LeapSRPRegister(
- schema="https",
- provider=full_domain,
- verify=verify)
-
- update_signal.emit("head_sentinel", 0)
+ yield(("head_sentinel", 0), lambda: None)
##################################################
- # 1) register user
+ # 1) fetching eip service config
##################################################
- # only if from signup.
-
- if is_signup:
-
- step = "register"
- update_signal.emit("checking availability", 20)
- update_signal.emit("registering with provider", 40)
- logger.debug('registering user')
-
+ def fetcheipconf():
try:
- ok, req = signup.register_user(
- username, password)
-
- except socket.timeout:
- self.set_error(
- step,
- "Error connecting to provider (timeout)")
- pause_for_user()
- return False
-
- except requests.exceptions.ConnectionError as exc:
- logger.error(exc.message)
- self.set_error(
- step,
- "Error connecting to provider "
- "(connection error)")
- # XXX we should signal a BAD step
- pause_for_user()
- update_signal.emit("connection error!", 50)
- pause_for_user()
- return False
-
- # XXX check for != OK instead???
-
- if req.status_code in (404, 500):
- self.set_error(
- step,
- "Error during registration (%s)" % req.status_code)
- pause_for_user()
- return False
-
- validation_msgs = json.loads(req.content)
- errors = validation_msgs.get('errors', None)
- logger.debug('validation errors: %s' % validation_msgs)
-
- if errors and errors.get('login', None):
- # XXX this sometimes catch the blank username
- # but we're not allowing that (soon)
- self.set_error(
- step,
- 'Username not available.')
- pause_for_user()
- return False
-
- pause_for_user()
+ eipconfigchecker.fetch_eip_service_config(
+ domain=full_domain)
- ##################################################
- # 2) fetching eip service config
- ##################################################
+ # XXX get specific exception
+ except Exception as exc:
+ return self.fail(exc.message)
- step = "fetch_eipconf"
- fetching_eipconf_msg = "Fetching eip service configuration"
- update_signal.emit(fetching_eipconf_msg, 60)
- try:
- eipconfigchecker.fetch_eip_service_config(
- domain=full_domain)
-
- # XXX get specific exception
- except:
- self.set_error(
- step,
- 'Could not download eip config.')
- pause_for_user()
- return False
- pause_for_user()
+ yield((self.tr("Fetching provider config..."), 40),
+ fetcheipconf)
##################################################
- # 3) getting client certificate
+ # 2) getting client certificate
##################################################
- # XXX maybe only do this if we come from signup
-
- step = "fetch_eipcert"
- fetching_clientcert_msg = "Fetching eip certificate"
- update_signal.emit(fetching_clientcert_msg, 80)
- try:
- pCertChecker.download_new_client_cert(
- credentials=credentials,
- verify=verify)
+ def fetcheipcert():
+ try:
+ pCertChecker.download_new_client_cert(
+ credentials=credentials,
+ verify=verify)
- except auth.SRPAuthenticationError as exc:
- self.set_error(
- step,
- "Authentication error: %s" % exc.message)
- return False
+ except auth.SRPAuthenticationError as exc:
+ return self.fail(self.tr(
+ "Authentication error: %s" % exc.message))
+ else:
+ return True
- pause_for_user()
+ yield((self.tr("Fetching eip certificate"), 80),
+ fetcheipcert)
################
# end !
################
+ self.set_done()
+ yield(("end_sentinel", 100), lambda: None)
- update_signal.emit("end_sentinel", 100)
- pause_for_user()
-
+ def on_checks_validation_ready(self):
+ """
+ called after _do_checks has finished
+ (connected to checker thread finished signal)
+ """
+ # this should be called CONNECT PAGE AGAIN.
# here we go! :)
+ full_domain = self.field('provider_domain')
+ domain, port = get_https_domain_and_port(full_domain)
+ _domain = u"%s:%s" % (domain, port) if port != 443 else unicode(domain)
self.run_eip_checks_for_provider_and_connect(_domain)
def run_eip_checks_for_provider_and_connect(self, domain):
@@ -225,6 +152,14 @@ class RegisterUserValidationPage(ValidationPage):
"probably the wizard has been launched "
"in an stand-alone way.")
+ # XXX look for a better place to signal
+ # we are done.
+ # We could probably have a fake validatePage
+ # that checks if the domain transfer has been
+ # done to conductor object, triggers the start_signal
+ # and does the go_next()
+ self.set_done()
+
def eip_error_check(self):
"""
a version of the main app error checker,
@@ -241,7 +176,8 @@ class RegisterUserValidationPage(ValidationPage):
called after _do_checks has finished
(connected to checker thread finished signal)
"""
- prevpage = "signup" if self.is_signup else "login"
+ is_signup = self.field("is_signup")
+ prevpage = "signup" if is_signup else "login"
wizard = self.wizard()
if self.errors:
@@ -253,13 +189,16 @@ class RegisterUserValidationPage(ValidationPage):
first_error)
self.go_back()
else:
- logger.debug('going next')
- # check if this "next" interferes
- # with the eip signal.
- self.go_next()
+ logger.debug('should go next, wait for user to click next')
+ #self.go_next()
def nextId(self):
wizard = self.wizard()
if not wizard:
return
return wizard.get_page_index('lastpage')
+
+ def initializePage(self):
+ super(RegisterUserValidationPage, self).initializePage()
+ self.set_undone()
+ self.completeChanged.emit()