diff options
author | Moritz Poldrack <git@moritz.sh> | 2022-12-18 17:05:41 +0100 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2022-12-20 09:46:43 +0100 |
commit | dd89c7c44ba1b74c6a263c843e5d9ff00e9c2a18 (patch) | |
tree | 4a5fb94c3fe116162d3c47a6b2626001bec51b9c /widgets | |
parent | 4d446719a815b64cd6482c338e364ff8848c8a71 (diff) | |
download | aerc-dd89c7c44ba1b74c6a263c843e5d9ff00e9c2a18.tar.gz |
wizard: debounce warning to ensure pasted passwords are entered correctly
When entering passwords from a password-manager the wizard shows it's
warning right after the first character has been pasted and the rest of
the password is lost.
Debounce the displaying of the "stored in plaintext"-warning to only
show after the password has been entered.
Reported-by: qbit (@qbit:tapenet.org)
Signed-off-by: Moritz Poldrack <git@moritz.sh>
Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'widgets')
-rw-r--r-- | widgets/account-wizard.go | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/widgets/account-wizard.go b/widgets/account-wizard.go index 0e2bda1e..2ff87241 100644 --- a/widgets/account-wizard.go +++ b/widgets/account-wizard.go @@ -11,6 +11,7 @@ import ( "strconv" "strings" "sync" + "time" "github.com/gdamore/tcell/v2" "github.com/go-ini/ini" @@ -133,11 +134,21 @@ func NewAccountWizard(aerc *Aerc) *AccountWizard { wizard.smtpUri() }) var once sync.Once + var lastChange time.Time wizard.imapPassword.OnChange(func(_ *ui.TextInput) { wizard.smtpPassword.Set(wizard.imapPassword.String()) wizard.imapUri() wizard.smtpUri() - once.Do(func() { showPasswordWarning(aerc) }) + lastChange = time.Now() + once.Do(func() { + // debounce to ensure pasted passwords are pasted completely + go func() { + for !time.Now().After(lastChange.Add(10 * time.Millisecond)) { + <-time.After(10 * time.Millisecond) + } + showPasswordWarning(aerc) + }() + }) }) wizard.smtpServer.OnChange(func(_ *ui.TextInput) { wizard.smtpUri() |