diff options
| author | Ivan Alejandro <ivanalejandro0@gmail.com> | 2013-10-31 16:30:21 -0300 | 
|---|---|---|
| committer | Ivan Alejandro <ivanalejandro0@gmail.com> | 2013-10-31 16:44:45 -0300 | 
| commit | 51cfd78c39d8eeab0c3004b7acb3ce0411742556 (patch) | |
| tree | 1661ecf77c7d90043ab4e75d299d8b28250e8c4d | |
| parent | 553bc677db6e24758c8a0d842de0d1839118271e (diff) | |
Password change policy improvement.
Only allow the user to change its password if is logged in and:
- provider supports email and its started.
- provider does not support email.
In case that the conditions needed are not fullfiled, show the user the
actions needed to be able to change its password.
[Closes #4093]
| -rw-r--r-- | changes/bug-4093_change-password-policy | 2 | ||||
| -rw-r--r-- | src/leap/bitmask/gui/mainwindow.py | 10 | ||||
| -rw-r--r-- | src/leap/bitmask/gui/preferenceswindow.py | 37 | 
3 files changed, 42 insertions, 7 deletions
| diff --git a/changes/bug-4093_change-password-policy b/changes/bug-4093_change-password-policy new file mode 100644 index 00000000..87f6fd15 --- /dev/null +++ b/changes/bug-4093_change-password-policy @@ -0,0 +1,2 @@ +  - Enable password change in the client only if it has started the correct +    services. Closes #4093. diff --git a/src/leap/bitmask/gui/mainwindow.py b/src/leap/bitmask/gui/mainwindow.py index ce3f113b..5eb9e6dc 100644 --- a/src/leap/bitmask/gui/mainwindow.py +++ b/src/leap/bitmask/gui/mainwindow.py @@ -446,13 +446,11 @@ class MainWindow(QtGui.QMainWindow):          Displays the preferences window.          """ -        preferences_window = PreferencesWindow(self, self._srp_auth) +        preferences_window = PreferencesWindow(self, self._srp_auth, +                                               self._provider_config) -        if sameProxiedObjects(self._soledad, None): -            preferences_window.set_soledad_ready(self._soledad) -        else: -            self.soledad_ready.connect( -                lambda: preferences_window.set_soledad_ready(self._soledad)) +        self.soledad_ready.connect( +            lambda: preferences_window.set_soledad_ready(self._soledad))          preferences_window.show() diff --git a/src/leap/bitmask/gui/preferenceswindow.py b/src/leap/bitmask/gui/preferenceswindow.py index b043afe6..86fe9433 100644 --- a/src/leap/bitmask/gui/preferenceswindow.py +++ b/src/leap/bitmask/gui/preferenceswindow.py @@ -40,12 +40,14 @@ class PreferencesWindow(QtGui.QDialog):      """      Window that displays the preferences.      """ -    def __init__(self, parent, srp_auth): +    def __init__(self, parent, srp_auth, provider_config):          """          :param parent: parent object of the PreferencesWindow.          :parent type: QWidget          :param srp_auth: SRPAuth object configured in the main app.          :type srp_auth: SRPAuth +        :param provider_config: ProviderConfig object. +        :type provider_config: ProviderConfig          """          QtGui.QDialog.__init__(self, parent)          self.AUTOMATIC_GATEWAY_LABEL = self.tr("Automatic") @@ -72,6 +74,35 @@ class PreferencesWindow(QtGui.QDialog):          else:              self._add_configured_providers() +        pw_enabled = False + +        # check if the user is logged in +        if srp_auth is not None and srp_auth.get_session_id() is not None: +            # check if provider has 'mx' ... +            if provider_config.provides_mx(): +                domain = provider_config.get_domain() +                enabled_services = self._settings.get_enabled_services(domain) +                mx_name = get_service_display_name('mx') + +                # ... and if the user have it enabled +                if 'mx' not in enabled_services: +                    msg = self.tr("You need to enable {0} in order to change " +                                  "the password.".format(mx_name)) +                    self._set_password_change_status(msg, error=True) +                else: +                    msg = self.tr( +                        "You need to wait until {0} is ready in " +                        "order to change the password.".format(mx_name)) +                    self._set_password_change_status(msg) +            else: +                pw_enabled = True +        else: +            msg = self.tr( +                "In order to change your password you need to be logged in.") +            self._set_password_change_status(msg) + +        self.ui.gbPasswordChange.setEnabled(pw_enabled) +      def set_soledad_ready(self, soledad):          """          SLOT @@ -84,6 +115,7 @@ class PreferencesWindow(QtGui.QDialog):          :type soledad: Soledad          """          self._soledad = soledad +        self.ui.lblPasswordChangeStatus.setVisible(False)          self.ui.gbPasswordChange.setEnabled(True)      def _set_password_change_status(self, status, error=False, success=False): @@ -98,6 +130,9 @@ class PreferencesWindow(QtGui.QDialog):          elif success:              status = "<font color='green'><b>%s</b></font>" % (status,) +        if not self.ui.gbPasswordChange.isEnabled(): +            status = "<font color='black'>%s</font>" % (status,) +          self.ui.lblPasswordChangeStatus.setVisible(True)          self.ui.lblPasswordChangeStatus.setText(status) | 
