summaryrefslogtreecommitdiff
path: root/src/leap
diff options
context:
space:
mode:
authorTomás Touceda <chiiph@leap.se>2013-03-12 14:11:56 -0300
committerTomás Touceda <chiiph@leap.se>2013-03-12 14:11:56 -0300
commit66464e6a2ea48d3dbafaa7c11b14478e7d34ab4d (patch)
treedb862532f1a6ef97b3b155aa2bd3fe461226ca17 /src/leap
parentcabfa92593d0c21f63f218842af8ed2bfba77cde (diff)
Login after register
Also, mark error in red and bold in the register form
Diffstat (limited to 'src/leap')
-rw-r--r--src/leap/gui/ui/wizard.ui84
-rw-r--r--src/leap/gui/wizard.py44
2 files changed, 83 insertions, 45 deletions
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 @@
<string notr="true">4</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_7">
- <item row="1" column="0" colspan="3">
- <widget class="QLabel" name="lblRegisterStatus">
- <property name="text">
- <string/>
- </property>
- <property name="textFormat">
- <enum>Qt::AutoText</enum>
- </property>
- <property name="alignment">
- <set>Qt::AlignCenter</set>
- </property>
- </widget>
- </item>
- <item row="6" column="1">
- <spacer name="verticalSpacer_7">
- <property name="orientation">
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>20</width>
- <height>40</height>
- </size>
- </property>
- </spacer>
- </item>
- <item row="2" column="0">
- <widget class="QLabel" name="label_15">
- <property name="text">
- <string>&lt;b&gt;User:&lt;/b&gt;</string>
- </property>
- <property name="alignment">
- <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
- </property>
- </widget>
- </item>
<item row="3" column="0">
<widget class="QLabel" name="label_16">
<property name="text">
@@ -600,7 +564,7 @@
</property>
</widget>
</item>
- <item row="5" column="1">
+ <item row="6" column="1">
<widget class="QPushButton" name="btnRegister">
<property name="text">
<string>Register</string>
@@ -620,6 +584,52 @@
</property>
</spacer>
</item>
+ <item row="1" column="0" colspan="3">
+ <widget class="QLabel" name="lblRegisterStatus">
+ <property name="text">
+ <string/>
+ </property>
+ <property name="textFormat">
+ <enum>Qt::AutoText</enum>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item row="7" column="1">
+ <spacer name="verticalSpacer_7">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="label_15">
+ <property name="text">
+ <string>&lt;b&gt;User:&lt;/b&gt;</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="1" colspan="2">
+ <widget class="QCheckBox" name="chkRemember">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Remember my username and password</string>
+ </property>
+ </widget>
+ </item>
</layout>
</widget>
<widget class="WizardPage" name="eip_setup_page">
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("<font color='green'>"
- "<b>User registration OK</b></font>"))
+ "<b>User registration OK. "
+ "Logging in...</b></font>"))
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("<font color='green'>"
+ "<b>Login succeeded!"
+ "</b></font>"))
+ 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 = "<font color='red'><b>%s</b></font>" % (status,)
self.ui.lblRegisterStatus.setText(status)
def _reset_provider_check(self):