[gnome-shell/T29763: 139/249] passwordReset: Reimplement password hint feature



commit f6d900105423a833e87948ec4fe4379047318e0a
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

 js/gdm/authPrompt.js | 40 ++++++++++++++++++++++++++++++++++++++--
 1 file changed, 38 insertions(+), 2 deletions(-)
---
diff --git a/js/gdm/authPrompt.js b/js/gdm/authPrompt.js
index 4b5d90d339..5089b244a1 100644
--- a/js/gdm/authPrompt.js
+++ b/js/gdm/authPrompt.js
@@ -138,6 +138,23 @@ var AuthPrompt = GObject.registerClass({
         this._message.clutter_text.ellipsize = Pango.EllipsizeMode.NONE;
         this.add_child(this._message);
 
+        let passwordHintLabel = new St.Label({
+            text: _('Show password hint'),
+            style_class: 'login-dialog-password-recovery-label',
+        });
+        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: Clutter.ActorAlign.CENTER,
+            x_expand: true,
+            visible: false,
+        });
+        this.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-label',
@@ -216,7 +233,8 @@ var AuthPrompt = GObject.registerClass({
         [this._textEntry, this._passwordEntry].forEach(entry => {
             entry.clutter_text.connect('text-changed', () => {
                 if (!this._passwordResetCode) {
-                    if (!this._userVerifier.hasPendingMessages)
+                    if (!this._userVerifier.hasPendingMessages &&
+                        !this._displayingPasswordHint)
                         this._fadeOutMessage();
 
                     this._canActivateNext =
@@ -341,7 +359,12 @@ var AuthPrompt = GObject.registerClass({
 
         Util.wiggle(this._entry);
 
-        this._maybeShowPasswordResetButton();
+        const userManager = AccountsService.UserManager.get_default();
+        const user = userManager.get_user(this._username);
+        if (user.get_password_hint().length > 0)
+            this._passwordHintButton.show();
+        else
+            this._maybeShowPasswordResetButton();
     }
 
     _onVerificationComplete() {
@@ -483,6 +506,8 @@ var AuthPrompt = GObject.registerClass({
         } else {
             this._message.opacity = 0;
         }
+
+        this._displayingPasswordHint = false;
     }
 
     updateSensitivity(sensitive) {
@@ -531,6 +556,7 @@ var AuthPrompt = GObject.registerClass({
         this._updateEntry(true);
         this.stopSpinning();
 
+        this._passwordHintButton.visible = false;
         this._passwordResetButton.visible = false;
         this._passwordResetCode = null;
 
@@ -795,4 +821,14 @@ var AuthPrompt = GObject.registerClass({
         this.updateSensitivity(true);
         this._message.text = _('Your unlock code was incorrect. Please try again.');
     }
+
+    _showPasswordHint() {
+        const userManager = AccountsService.UserManager.get_default();
+        const user = userManager.get_user(this._username);
+
+        this.setMessage(user.get_password_hint());
+        this._displayingPasswordHint = true;
+        this._passwordHintButton.hide();
+        this._maybeShowPasswordResetButton();
+    }
 });


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