Hide all passwords upon form submission in Core/Ui/Password.ts
authorTim Düsterhus <duesterhus@woltlab.com>
Wed, 20 Oct 2021 09:58:35 +0000 (11:58 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Wed, 20 Oct 2021 09:58:35 +0000 (11:58 +0200)
Resolves #4554

ts/WoltLabSuite/Core/Ui/Password.ts
wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Password.js

index 7576117fe5a30efea4d39e7e2697bdeb1ea48166..84b87602076eb6389812cd49825930d0a36df287 100644 (file)
@@ -57,6 +57,15 @@ function initElement(input: HTMLInputElement): void {
     }
   });
 
+  // Hide the password when the form is being submitted to prevent
+  // it from being stored within the web browser's autocomplete list.
+  // see https://github.com/WoltLab/WCF/issues/4554
+  input.form?.addEventListener("submit", () => {
+    if (input.type !== "password") {
+      toggle(input, button, icon);
+    }
+  });
+
   if (activeElement === input) {
     input.focus();
   }
index 1279d79b30a02eb35fb4a9634168c4744f611a47..27caa046617d7c3f9d2fed60cac318d108539c63 100644 (file)
@@ -26,6 +26,7 @@ define(["require", "exports", "tslib", "../Dom/Change/Listener", "../Language"],
         });
     }
     function initElement(input) {
+        var _a;
         _knownElements.add(input);
         const activeElement = document.activeElement;
         const inputAddon = document.createElement("div");
@@ -51,6 +52,14 @@ define(["require", "exports", "tslib", "../Dom/Change/Listener", "../Language"],
                 toggle(input, button, icon);
             }
         });
+        // Hide the password when the form is being submitted to prevent
+        // it from being stored within the web browser's autocomplete list.
+        // see https://github.com/WoltLab/WCF/issues/4554
+        (_a = input.form) === null || _a === void 0 ? void 0 : _a.addEventListener("submit", () => {
+            if (input.type !== "password") {
+                toggle(input, button, icon);
+            }
+        });
         if (activeElement === input) {
             input.focus();
         }