[epiphany/gnome-3-34] Make password manager user account selector actually work



commit b22460e11f00228490f9a4096f352ab6d6b516c3
Author: Michael Catanzaro <mcatanzaro gnome org>
Date:   Wed Feb 5 21:02:10 2020 +0000

    Make password manager user account selector actually work
    
    I broke this in 4e1f237f by changing FormManager.preFill() to require a
    formAuth parameter, but not updating every callsite.
    
    I think it was probably broken even before that, though, because there
    was no code to update the formAuth when changing the selected username.
    We have to do that too before calling preFill(). Also, blank out the
    password field beforehand just in case we fail to fill in the password,
    to avoid any possibility of using the old password for the new username.
    
    Fixes #1018
    
    
    (cherry picked from commit d41289ee1f63223e1dab72a4b4a23020425b4a65)

 embed/web-process-extension/resources/js/ephy.js | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)
---
diff --git a/embed/web-process-extension/resources/js/ephy.js 
b/embed/web-process-extension/resources/js/ephy.js
index 7f0a65679..0f3526e09 100644
--- a/embed/web-process-extension/resources/js/ephy.js
+++ b/embed/web-process-extension/resources/js/ephy.js
@@ -103,12 +103,13 @@ Ephy.getWebAppIcon = function(baseURL)
 
 Ephy.PreFillUserMenu = class PreFillUserMenu
 {
-    constructor(manager, userElement, users, passwordElement)
+    constructor(manager, formAuth, users)
     {
         this._manager = manager;
-        this._userElement = userElement;
+        this._formAuth = formAuth;
+        this._userElement = formAuth.usernameNode;
         this._users = users;
-        this._passwordElement = passwordElement;
+        this._passwordElement = formAuth.passwordNode;
         this._selected = null;
         this._wasEdited = false;
 
@@ -165,7 +166,7 @@ Ephy.PreFillUserMenu = class PreFillUserMenu
         if (newSelect) {
             this._selected = newSelect;
             this._userElement.value = this._selected.firstElementChild.textContent;
-            this._manager.preFill();
+            this._usernameSelected();
         } else {
             this._passwordElement.value = '';
         }
@@ -233,7 +234,7 @@ Ephy.PreFillUserMenu = class PreFillUserMenu
                 this._userElement.value = user;
                 this._selected = li;
                 this._removeMenu();
-                this._manager.preFill();
+                this._usernameSelected();
             }, true);
         }
 
@@ -249,6 +250,13 @@ Ephy.PreFillUserMenu = class PreFillUserMenu
         if (menu)
             menu.parentNode.removeChild(menu);
     }
+
+    _usernameSelected()
+    {
+        this._formAuth.username = this._userElement.value;
+        this._passwordElement.value = '';
+        this._manager.preFill(this._formAuth);
+    }
 }
 
 Ephy.formControlsAssociated = function(pageID, frameID, forms, serializer)
@@ -448,7 +456,7 @@ Ephy.FormManager = class FormManager
             Ephy.passwordManager.queryUsernames(formAuth.origin).then(users => {
                 if (users.length > 1) {
                     Ephy.log('More than one saved username, hooking menu for choosing which one to select');
-                    this._preFillUserMenu = new Ephy.PreFillUserMenu(this, formAuth.usernameNode, users, 
formAuth.passwordNode);
+                    this._preFillUserMenu = new Ephy.PreFillUserMenu(this, formAuth, users);
                 }
                 this.preFill(formAuth);
             });


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