diff options
author | Ivan Alejandro <ivanalejandro0@yahoo.com.ar> | 2013-06-07 12:10:08 -0300 |
---|---|---|
committer | Ivan Alejandro <ivanalejandro0@yahoo.com.ar> | 2013-06-07 15:06:59 -0300 |
commit | 3e4ccef05a02c7b717b392acbb6201b2f8858a91 (patch) | |
tree | da9a3e38a35a61b9254eb8b0797eab58fb4346ed /src | |
parent | 269f6535fb468ab6789d3efef27c272178e31395 (diff) |
Remember provider along with username and password
Diffstat (limited to 'src')
-rw-r--r-- | src/leap/gui/mainwindow.py | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/src/leap/gui/mainwindow.py b/src/leap/gui/mainwindow.py index f9e088a7..96c50201 100644 --- a/src/leap/gui/mainwindow.py +++ b/src/leap/gui/mainwindow.py @@ -405,8 +405,21 @@ class MainWindow(QtGui.QMainWindow): saved_user = self._settings.get_user() auto_login = self._settings.get_autologin() + try: + username, domain = saved_user.split('@') + except (ValueError, AttributeError) as e: + # if the saved_user does not contain an '@' or its None + logger.error('Username@provider malformed. %r' % (e, )) + saved_user = None + if saved_user is not None: - self.ui.lnUser.setText(saved_user) + # fill the username + self.ui.lnUser.setText(username) + + # select the configured provider in the combo box + provider_index = self.ui.cmbProviders.findText(domain) + self.ui.cmbProviders.setCurrentIndex(provider_index) + self.ui.chkRemember.setChecked(True) self.ui.chkAutoLogin.setEnabled(self.ui.chkRemember .isEnabled()) @@ -699,13 +712,16 @@ class MainWindow(QtGui.QMainWindow): self._login_set_enabled(False) if self.ui.chkRemember.isChecked(): + # in the keyring and in the settings + # we store the value 'usename@provider' + username_domain = (username + '@' + provider).encode("utf8") try: keyring.set_password(self.KEYRING_KEY, - username.encode("utf8"), + username_domain, password.encode("utf8")) # Only save the username if it was saved correctly in # the keyring - self._settings.set_user(username) + self._settings.set_user(username_domain) except Exception as e: logger.error("Problem saving data to keyring. %r" % (e,)) |