[gnome-shell/T27795: 126/138] passwordReset: Reimplement password hint feature



commit 1d995fa8d3c790772aceb53f91ab600cdb1b86d4
Author: Mario Sanchez Prada <mario endlessm com>
Date:   Tue Sep 12 17:18:56 2017 +0100

    passwordReset: Reimplement password hint feature
    
    This helps users to remember their passwords without needing
    to call customer support.
    
    https://phabricator.endlessm.com/T17245

 data/org.gnome.shell.gschema.xml.in | 11 +++++-----
 js/gdm/authPrompt.js                | 40 +++++++++++++++++++++++++++++++++++--
 2 files changed, 43 insertions(+), 8 deletions(-)
---
diff --git a/data/org.gnome.shell.gschema.xml.in b/data/org.gnome.shell.gschema.xml.in
index 90917ee980..2376881b57 100644
--- a/data/org.gnome.shell.gschema.xml.in
+++ b/data/org.gnome.shell.gschema.xml.in
@@ -1,6 +1,11 @@
 <schemalist>
   <!-- Keep Endless-specific enumerations at the top of the file -->
 
+  <enum id="org.gnome.shell.PasswordResetPolicy">
+    <value nick="default" value="-1"/>
+    <value nick="disable" value="0"/>
+    <value nick="enable" value="1"/>
+  </enum>
   <enum id="org.gnome.shell.watermark.Position">
     <value nick="center" value="0"/>
     <value nick="bottom-left" value="1"/>
@@ -123,12 +128,6 @@
 
     <!-- Endless-specific keys beyond this point -->
 
-    <enum id="org.gnome.shell.PasswordResetPolicy">
-      <value nick="default" value="-1"/>
-      <value nick="disable" value="0"/>
-      <value nick="enable" value="1"/>
-    </enum>
-
     <key name="enable-tray-area" type="b">
       <default>true</default>
       <summary>
diff --git a/js/gdm/authPrompt.js b/js/gdm/authPrompt.js
index dab0c1a199..0c40519613 100644
--- a/js/gdm/authPrompt.js
+++ b/js/gdm/authPrompt.js
@@ -126,6 +126,23 @@ var AuthPrompt = class {
                                         y_fill: true,
                                         y_align: St.Align.START });
 
+        let passwordHintLabel = new St.Label({
+            text: _("Show password hint"),
+            style_class: 'login-dialog-password-recovery-link',
+        });
+        this._passwordHintButton = new St.Button({
+            style_class: 'login-dialog-password-recovery-button',
+            button_mask: St.ButtonMask.ONE | St.ButtonMask.THREE,
+            can_focus: true,
+            child: passwordHintLabel,
+            reactive: true,
+            x_align: St.Align.START,
+            x_fill: true,
+            visible: false,
+        });
+        this.actor.add_child(this._passwordHintButton);
+        this._passwordHintButton.connect('clicked', this._showPasswordHint.bind(this));
+
         let passwordResetLabel = new St.Label({ text: _("Forgot password?"),
                                                 style_class: 'login-dialog-password-recovery-link' });
         this._passwordResetButton = new St.Button({ style_class: 'login-dialog-password-recovery-button',
@@ -209,8 +226,10 @@ var AuthPrompt = class {
 
         this._entry.clutter_text.connect('text-changed', () => {
             if (this._passwordResetCode == null) {
-                if (!this._userVerifier.hasPendingMessages)
+                if (!this._userVerifier.hasPendingMessages &&
+                    !this._displayingPasswordHint) {
                     this._fadeOutMessage();
+                }
                 this._updateNextButtonSensitivity(this._entry.text.length > 0 || this.verificationStatus == 
AuthPromptStatus.VERIFYING);
             } else {
                 // Password unlock code must contain the right number of digits, and only digits.
@@ -288,7 +307,12 @@ var AuthPrompt = class {
         this.setActorInDefaultButtonWell(null);
         this.verificationStatus = AuthPromptStatus.VERIFICATION_FAILED;
 
-        this._maybeShowPasswordResetButton();
+        let userManager = AccountsService.UserManager.get_default();
+        let user = userManager.get_user(this._username);
+        if (user.get_password_hint().length > 0)
+            this._passwordHintButton.show();
+        else
+            this._maybeShowPasswordResetButton();
     }
 
     _onVerificationComplete() {
@@ -439,6 +463,8 @@ var AuthPrompt = class {
         } else {
             this._message.opacity = 0;
         }
+
+        this._displayingPasswordHint = false;
     }
 
     _updateNextButtonSensitivity(sensitive) {
@@ -491,6 +517,7 @@ var AuthPrompt = class {
         this.setUser(null);
         this.stopSpinning();
 
+        this._passwordHintButton.visible = false;
         this._passwordResetButton.visible = false;
         this._passwordResetCode = null;
 
@@ -742,5 +769,14 @@ var AuthPrompt = class {
          this.updateSensitivity(true);
          this._message.text = _("Your unlock code was incorrect. Please try again.");
     }
+
+    _showPasswordHint() {
+        let userManager = AccountsService.UserManager.get_default();
+        let user = userManager.get_user(this._username);
+        this.setMessage(user.get_password_hint());
+        this._displayingPasswordHint = true;
+        this._passwordHintButton.hide();
+        this._maybeShowPasswordResetButton();
+    }
 };
 Signals.addSignalMethods(AuthPrompt.prototype);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]