From c348834ce94a35c49a121034d89169139602b5b3 Mon Sep 17 00:00:00 2001 From: Mechiel Lukkien Date: Fri, 5 Jan 2024 12:15:55 +0100 Subject: [PATCH] prevent firefox from autocompleting the current password in the form/fields for changing password --- lib.ts | 1 + webaccount/account.js | 5 +++-- webaccount/account.ts | 4 ++-- webadmin/admin.js | 3 ++- webadmin/admin.ts | 2 +- webmail/msg.js | 1 + webmail/text.js | 1 + webmail/webmail.js | 1 + 8 files changed, 12 insertions(+), 6 deletions(-) diff --git a/lib.ts b/lib.ts index f8813be..816e94f 100644 --- a/lib.ts +++ b/lib.ts @@ -213,6 +213,7 @@ const attr = { max: (s: string) => _attr('max', s), action: (s: string) => _attr('action', s), method: (s: string) => _attr('method', s), + autocomplete: (s: string) => _attr('autocomplete', s), } const style = (x: {[k: string]: string | number}) => { return {_styles: x}} const prop = (x: {[k: string]: any}) => { return {_props: x}} diff --git a/webaccount/account.js b/webaccount/account.js index b84a36f..2c36194 100644 --- a/webaccount/account.js +++ b/webaccount/account.js @@ -217,6 +217,7 @@ const [dom, style, attr, prop] = (function () { max: (s) => _attr('max', s), action: (s) => _attr('action', s), method: (s) => _attr('method', s), + autocomplete: (s) => _attr('autocomplete', s), }; const style = (x) => { return { _styles: x }; }; const prop = (x) => { return { _props: x }; }; @@ -913,9 +914,9 @@ const index = async () => { finally { fullNameFieldset.disabled = false; } - }), dom.br(), dom.h2('Addresses'), dom.ul(Object.entries(destinations).sort().map(t => dom.li(dom.a(t[0], attr.href('#destinations/' + t[0])), t[0].startsWith('@') ? ' (catchall)' : []))), dom.br(), dom.h2('Change password'), passwordForm = dom.form(passwordFieldset = dom.fieldset(dom.label(style({ display: 'inline-block' }), 'New password', dom.br(), password1 = dom.input(attr.type('password'), attr.required(''), function focus() { + }), dom.br(), dom.h2('Addresses'), dom.ul(Object.entries(destinations).sort().map(t => dom.li(dom.a(t[0], attr.href('#destinations/' + t[0])), t[0].startsWith('@') ? ' (catchall)' : []))), dom.br(), dom.h2('Change password'), passwordForm = dom.form(passwordFieldset = dom.fieldset(dom.label(style({ display: 'inline-block' }), 'New password', dom.br(), password1 = dom.input(attr.type('password'), attr.autocomplete('new-password'), attr.required(''), function focus() { passwordHint.style.display = ''; - })), ' ', dom.label(style({ display: 'inline-block' }), 'New password repeat', dom.br(), password2 = dom.input(attr.type('password'), attr.required(''))), ' ', dom.submitbutton('Change password')), passwordHint = dom.div(style({ display: 'none', marginTop: '.5ex' }), dom.clickbutton('Generate random password', function click(e) { + })), ' ', dom.label(style({ display: 'inline-block' }), 'New password repeat', dom.br(), password2 = dom.input(attr.type('password'), attr.autocomplete('new-password'), attr.required(''))), ' ', dom.submitbutton('Change password')), passwordHint = dom.div(style({ display: 'none', marginTop: '.5ex' }), dom.clickbutton('Generate random password', function click(e) { e.preventDefault(); let b = new Uint8Array(1); let s = ''; diff --git a/webaccount/account.ts b/webaccount/account.ts index 9892b8d..3521b11 100644 --- a/webaccount/account.ts +++ b/webaccount/account.ts @@ -348,7 +348,7 @@ const index = async () => { style({display: 'inline-block'}), 'New password', dom.br(), - password1=dom.input(attr.type('password'), attr.required(''), function focus() { + password1=dom.input(attr.type('password'), attr.autocomplete('new-password'), attr.required(''), function focus() { passwordHint.style.display = '' }), ), @@ -357,7 +357,7 @@ const index = async () => { style({display: 'inline-block'}), 'New password repeat', dom.br(), - password2=dom.input(attr.type('password'), attr.required('')), + password2=dom.input(attr.type('password'), attr.autocomplete('new-password'), attr.required('')), ), ' ', dom.submitbutton('Change password'), diff --git a/webadmin/admin.js b/webadmin/admin.js index 5ca8726..9662199 100644 --- a/webadmin/admin.js +++ b/webadmin/admin.js @@ -217,6 +217,7 @@ const [dom, style, attr, prop] = (function () { max: (s) => _attr('max', s), action: (s) => _attr('action', s), method: (s) => _attr('method', s), + autocomplete: (s) => _attr('autocomplete', s), }; const style = (x) => { return { _styles: x }; }; const prop = (x) => { return { _props: x }; }; @@ -1850,7 +1851,7 @@ const account = async (name) => { finally { fieldsetLimits.disabled = false; } - }), dom.br(), dom.h2('Set new password'), formPassword = dom.form(fieldsetPassword = dom.fieldset(dom.label(style({ display: 'inline-block' }), 'New password', dom.br(), password = dom.input(attr.type('password'), attr.required(''), function focus() { + }), dom.br(), dom.h2('Set new password'), formPassword = dom.form(fieldsetPassword = dom.fieldset(dom.label(style({ display: 'inline-block' }), 'New password', dom.br(), password = dom.input(attr.type('password'), attr.autocomplete('new-password'), attr.required(''), function focus() { passwordHint.style.display = ''; })), ' ', dom.submitbutton('Change password')), passwordHint = dom.div(style({ display: 'none', marginTop: '.5ex' }), dom.clickbutton('Generate random password', function click(e) { e.preventDefault(); diff --git a/webadmin/admin.ts b/webadmin/admin.ts index d9c70cb..b024855 100644 --- a/webadmin/admin.ts +++ b/webadmin/admin.ts @@ -757,7 +757,7 @@ const account = async (name: string) => { style({display: 'inline-block'}), 'New password', dom.br(), - password=dom.input(attr.type('password'), attr.required(''), function focus() { + password=dom.input(attr.type('password'), attr.autocomplete('new-password'), attr.required(''), function focus() { passwordHint.style.display = '' }), ), diff --git a/webmail/msg.js b/webmail/msg.js index 2798225..8e3e16f 100644 --- a/webmail/msg.js +++ b/webmail/msg.js @@ -217,6 +217,7 @@ const [dom, style, attr, prop] = (function () { max: (s) => _attr('max', s), action: (s) => _attr('action', s), method: (s) => _attr('method', s), + autocomplete: (s) => _attr('autocomplete', s), }; const style = (x) => { return { _styles: x }; }; const prop = (x) => { return { _props: x }; }; diff --git a/webmail/text.js b/webmail/text.js index 5a8ebd6..ccb643c 100644 --- a/webmail/text.js +++ b/webmail/text.js @@ -217,6 +217,7 @@ const [dom, style, attr, prop] = (function () { max: (s) => _attr('max', s), action: (s) => _attr('action', s), method: (s) => _attr('method', s), + autocomplete: (s) => _attr('autocomplete', s), }; const style = (x) => { return { _styles: x }; }; const prop = (x) => { return { _props: x }; }; diff --git a/webmail/webmail.js b/webmail/webmail.js index 74035e0..7558b6f 100644 --- a/webmail/webmail.js +++ b/webmail/webmail.js @@ -217,6 +217,7 @@ const [dom, style, attr, prop] = (function () { max: (s) => _attr('max', s), action: (s) => _attr('action', s), method: (s) => _attr('method', s), + autocomplete: (s) => _attr('autocomplete', s), }; const style = (x) => { return { _styles: x }; }; const prop = (x) => { return { _props: x }; };