From: Tim Düsterhus Date: Wed, 20 Oct 2021 09:58:35 +0000 (+0200) Subject: Hide all passwords upon form submission in Core/Ui/Password.ts X-Git-Tag: 5.4.9_dev_1~40^2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=475823821b5c475d5b352cdf5dabe4a835dca589;p=GitHub%2FWoltLab%2FWCF.git Hide all passwords upon form submission in Core/Ui/Password.ts Resolves #4554 --- diff --git a/ts/WoltLabSuite/Core/Ui/Password.ts b/ts/WoltLabSuite/Core/Ui/Password.ts index 7576117fe5..84b8760207 100644 --- a/ts/WoltLabSuite/Core/Ui/Password.ts +++ b/ts/WoltLabSuite/Core/Ui/Password.ts @@ -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(); } diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Password.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Password.js index 1279d79b30..27caa04661 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Password.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Password.js @@ -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(); }