diff options
author | Koni Marti <koni.marti@gmail.com> | 2023-08-02 11:54:13 +0200 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2023-08-03 22:25:42 +0200 |
commit | 6713a8f4588f26f46c3e5fe0a69ead0f345617f3 (patch) | |
tree | e4ad5c23af2b812450acd151b158a1e2f4f21b61 | |
parent | e32cf3d478e746e1a83a1289e47399087fe1fda3 (diff) | |
download | aerc-6713a8f4588f26f46c3e5fe0a69ead0f345617f3.tar.gz |
wizard: display warning when focus is lost
Display the warning that the password is stored in plaintext after the
focus of the password input field is lost.
The current behavior of showing the warning after the first character is
entered is ackward and confusing.
It also eliminates the need to debounce the warning when a password is
pasted.
Reported-by: Brad <super1337@posteo.net>
Signed-off-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
-rw-r--r-- | commands/new-account.go | 1 | ||||
-rw-r--r-- | lib/ui/tab.go | 6 | ||||
-rw-r--r-- | widgets/account-wizard.go | 29 |
3 files changed, 20 insertions, 16 deletions
diff --git a/commands/new-account.go b/commands/new-account.go index 2747b159..d67b5eca 100644 --- a/commands/new-account.go +++ b/commands/new-account.go @@ -32,6 +32,7 @@ func (NewAccount) Execute(aerc *widgets.Aerc, args []string) error { wizard.ConfigureTemporaryAccount(true) } } + wizard.Focus(true) aerc.NewTab(wizard, "New account") return nil } diff --git a/lib/ui/tab.go b/lib/ui/tab.go index b62764fb..6a5cbf50 100644 --- a/lib/ui/tab.go +++ b/lib/ui/tab.go @@ -157,6 +157,9 @@ func (tabs *Tabs) selectPriv(index int) bool { if vis, ok := prev.Content.(Visible); ok { vis.Show(false) } + if vis, ok := prev.Content.(Interactive); ok { + vis.Focus(false) + } tabs.pushHistory(tabs.curIndex) } tabs.curIndex = index @@ -164,6 +167,9 @@ func (tabs *Tabs) selectPriv(index int) bool { if vis, ok := next.Content.(Visible); ok { vis.Show(true) } + if vis, ok := next.Content.(Interactive); ok { + vis.Focus(true) + } Invalidate() } return true diff --git a/widgets/account-wizard.go b/widgets/account-wizard.go index 8c9739e6..7fa371fc 100644 --- a/widgets/account-wizard.go +++ b/widgets/account-wizard.go @@ -11,7 +11,6 @@ import ( "strconv" "strings" "sync" - "time" "github.com/gdamore/tcell/v2" "github.com/go-ini/ini" @@ -19,7 +18,6 @@ import ( "git.sr.ht/~rjarry/aerc/config" "git.sr.ht/~rjarry/aerc/lib/ui" - "git.sr.ht/~rjarry/aerc/log" ) const ( @@ -74,10 +72,16 @@ type AccountWizard struct { } func showPasswordWarning(aerc *Aerc) { - title := "The Wizard will store your passwords in plaintext" - text := "It is recommended to remove the plaintext passwords " + - "and use your personal password store with " + - "'source-cred-cmd' and 'outgoing-cred-cmd' after the setup." + title := "ATTENTION" + text := ` +The Wizard will store your passwords as clear text in: + + ~/.config/aerc/accounts.conf + +It is recommended to remove the clear text passwords and configure +'source-cred-cmd' and 'outgoing-cred-cmd' using your own password store +after the setup. +` warning := NewSelectorDialog( title, text, []string{"OK"}, 0, aerc.SelectedAccountUiConfig(), @@ -135,21 +139,14 @@ 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() - lastChange = time.Now() + }) + wizard.imapPassword.OnFocusLost(func(_ *ui.TextInput) { once.Do(func() { - // debounce to ensure pasted passwords are pasted completely - go func() { - defer log.PanicHandler() - for !time.Now().After(lastChange.Add(10 * time.Millisecond)) { - <-time.After(10 * time.Millisecond) - } - showPasswordWarning(aerc) - }() + showPasswordWarning(aerc) }) }) wizard.smtpServer.OnChange(func(_ *ui.TextInput) { |