From 66464e6a2ea48d3dbafaa7c11b14478e7d34ab4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20Touceda?= Date: Tue, 12 Mar 2013 14:11:56 -0300 Subject: Login after register Also, mark error in red and bold in the register form --- src/leap/gui/ui/wizard.ui | 84 ++++++++++++++++++++++++++--------------------- src/leap/gui/wizard.py | 44 ++++++++++++++++++++----- 2 files changed, 83 insertions(+), 45 deletions(-) (limited to 'src/leap') diff --git a/src/leap/gui/ui/wizard.ui b/src/leap/gui/ui/wizard.ui index d44e8224..ad4c0500 100644 --- a/src/leap/gui/ui/wizard.ui +++ b/src/leap/gui/ui/wizard.ui @@ -535,42 +535,6 @@ 4 - - - - - - - Qt::AutoText - - - Qt::AlignCenter - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - <b>User:</b> - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - @@ -600,7 +564,7 @@ - + Register @@ -620,6 +584,52 @@ + + + + + + + Qt::AutoText + + + Qt::AlignCenter + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + <b>User:</b> + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + false + + + Remember my username and password + + + diff --git a/src/leap/gui/wizard.py b/src/leap/gui/wizard.py index de988153..1f0bc877 100644 --- a/src/leap/gui/wizard.py +++ b/src/leap/gui/wizard.py @@ -27,6 +27,7 @@ from functools import partial from ui_wizard import Ui_Wizard from leap.config.providerconfig import ProviderConfig from leap.crypto.srpregister import SRPRegister +from leap.crypto.srpauth import SRPAuth from leap.services.eip.providerbootstrapper import ProviderBootstrapper from leap.services.eip.eipbootstrapper import EIPBootstrapper @@ -60,9 +61,6 @@ class Wizard(QtGui.QWizard): self.setPixmap(QtGui.QWizard.LogoPixmap, QtGui.QPixmap(":/images/leap-color-small.png")) - self.setPixmap(QtGui.QWizard.WatermarkPixmap, - QtGui.QPixmap(":/images/watermark.png")) - self.QUESTION_ICON = QtGui.QPixmap(":/images/Emblem-question.png") self.ERROR_ICON = QtGui.QPixmap(":/images/Dialog-error.png") self.OK_ICON = QtGui.QPixmap(":/images/Dialog-accept.png") @@ -182,7 +180,7 @@ class Wizard(QtGui.QWizard): message = self.tr("Password equal to username") if message is not None: - self._set_register_status(message) + self._set_register_status(message, error=True) self._focus_password() return False @@ -215,10 +213,20 @@ class Wizard(QtGui.QWizard): def _registration_finished(self, ok, req): if ok: self._set_register_status(self.tr("" - "User registration OK")) + "User registration OK. " + "Logging in...")) self.ui.lblPassword2.clearFocus() - self.page(self.REGISTER_USER_PAGE).set_completed() - self.button(QtGui.QWizard.BackButton).setEnabled(False) + + srp_auth = SRPAuth(self._provider_config) + srp_auth.authentication_finished.connect( + self._authentication_finished) + + auth_partial = partial(srp_auth.authenticate, + self._username, + self._password) + self._checker_thread.add_checks([auth_partial]) + + self.ui.chkRemember.setEnabled(True) else: old_username = self._username self._username = None @@ -233,13 +241,33 @@ class Wizard(QtGui.QWizard): logger.error("Unknown error: %r" % (req.content,)) self.ui.btnRegister.setEnabled(True) - def _set_register_status(self, status): + def _authentication_finished(self, ok, message): + """ + SLOT + TRIGGER: srp_auth.authentication_finished + + Finish the authentication process as it comes from the + register form + """ + if ok: + self._set_register_status(self.tr("" + "Login succeeded!" + "")) + self.page(self.REGISTER_USER_PAGE).set_completed() + else: + self._set_register_status(message) + self.ui.btnRegister.setEnabled(True) + self.ui.chkRemember.setEnabled(False) + + def _set_register_status(self, status, error=False): """ Sets the status label in the registration page to status @param status: status message to display, can be HTML @type status: str """ + if error: + status = "%s" % (status,) self.ui.lblRegisterStatus.setText(status) def _reset_provider_check(self): -- cgit v1.2.3