summaryrefslogtreecommitdiff
path: root/src/leap/gui
diff options
context:
space:
mode:
authorTomás Touceda <chiiph@leap.se>2013-03-08 14:24:05 -0300
committerTomás Touceda <chiiph@leap.se>2013-03-08 14:24:05 -0300
commite4e5f35c3fc7ff02bc20a6ef7eaffae09f485061 (patch)
tree01f4775d17ff7c87153eb5b1beaf1d5d2d289481 /src/leap/gui
parent926575bc811e8382100695a3396da7191fb43eb3 (diff)
Add keyring and username/password saving capabilities
Also: - Fix translations in SRPAuth - Support non-ascii passwords - Make the server check if the characters are allowed, just check for easy passwords
Diffstat (limited to 'src/leap/gui')
-rw-r--r--src/leap/gui/mainwindow.py33
-rw-r--r--src/leap/gui/wizard.py11
2 files changed, 34 insertions, 10 deletions
diff --git a/src/leap/gui/mainwindow.py b/src/leap/gui/mainwindow.py
index d66ddbb5..68c73e4d 100644
--- a/src/leap/gui/mainwindow.py
+++ b/src/leap/gui/mainwindow.py
@@ -21,6 +21,7 @@ Main window for the leap client
import os
import logging
import random
+import keyring
from PySide import QtCore, QtGui
@@ -49,6 +50,9 @@ class MainWindow(QtGui.QMainWindow):
GEOMETRY_KEY = "Geometry"
WINDOWSTATE_KEY = "WindowState"
+ USER_KEY = "User"
+
+ KEYRING_KEY = "leap_client"
def __init__(self):
QtGui.QMainWindow.__init__(self)
@@ -183,6 +187,7 @@ class MainWindow(QtGui.QMainWindow):
if self._wizard is None:
self._wizard = Wizard(self._checker_thread)
self._wizard.exec_()
+ self._wizard = None
def _finish_init(self):
self.ui.cmbProviders.addItems(self._configured_providers())
@@ -194,6 +199,17 @@ class MainWindow(QtGui.QMainWindow):
self.ui.lnUser.setText(possible_username)
self._focus_password()
self._wizard = None
+ else:
+ settings = QtCore.QSettings()
+ saved_user = settings.value(self.USER_KEY, None)
+
+ if saved_user is not None:
+ self.ui.lnUser.setText(saved_user)
+ self.ui.chkRemember.setChecked(True)
+ saved_password = keyring.get_password(self.KEYRING_KEY,
+ saved_user
+ .encode("utf8"))
+ self.ui.lnPassword.setText(saved_password.decode("utf8"))
def _show_systray(self):
"""
@@ -442,6 +458,19 @@ class MainWindow(QtGui.QMainWindow):
self._set_status(self.tr("Logging in..."))
self._login_set_enabled(False)
+ if self.ui.chkRemember.isChecked():
+ try:
+ keyring.set_password(self.KEYRING_KEY,
+ username.encode("utf8"),
+ password.encode("utf8"))
+ # Only save the username if it was saved correctly in
+ # the keyring
+ settings = QtCore.QSettings()
+ settings.setValue(self.USER_KEY, username)
+ except Exception as e:
+ logger.error("Problem saving data to keyring. %r"
+ % (e,))
+
self._download_provider_config()
def _provider_config_loaded(self, data):
@@ -455,8 +484,8 @@ class MainWindow(QtGui.QMainWindow):
leap_assert(self._provider_config, "We need a provider config!")
if data[self._provider_bootstrapper.PASSED_KEY]:
- username = self.ui.lnUser.text()
- password = self.ui.lnPassword.text()
+ username = self.ui.lnUser.text().encode("utf8")
+ password = self.ui.lnPassword.text().encode("utf8")
if self._srp_auth is None:
self._srp_auth = SRPAuth(self._provider_config)
diff --git a/src/leap/gui/wizard.py b/src/leap/gui/wizard.py
index fa705645..72e791b3 100644
--- a/src/leap/gui/wizard.py
+++ b/src/leap/gui/wizard.py
@@ -148,13 +148,6 @@ class Wizard(QtGui.QWizard):
"""
message = None
- try:
- username.encode("ascii")
- password.encode("ascii")
- except:
- message = self.tr(u"Refrain from using non "
- u"ASCII characters like á, ñ, æ")
-
if message is not None and password != password2:
message = self.tr("Passwords don't match")
@@ -189,7 +182,9 @@ class Wizard(QtGui.QWizard):
register.registration_finished.connect(
self._registration_finished)
self._checker_thread.add_checks(
- [partial(register.register_user, username, password)])
+ [partial(register.register_user,
+ username.encode("utf8"),
+ password.encode("utf8"))])
self._username = username
self._set_register_status(self.tr("Starting registration..."))
else: