aboutsummaryrefslogtreecommitdiffstats
path: root/widgets
diff options
context:
space:
mode:
authorKoni Marti <koni.marti@gmail.com>2023-08-02 11:54:13 +0200
committerRobin Jarry <robin@jarry.cc>2023-08-03 22:25:42 +0200
commit6713a8f4588f26f46c3e5fe0a69ead0f345617f3 (patch)
treee4ad5c23af2b812450acd151b158a1e2f4f21b61 /widgets
parente32cf3d478e746e1a83a1289e47399087fe1fda3 (diff)
downloadaerc-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>
Diffstat (limited to 'widgets')
-rw-r--r--widgets/account-wizard.go29
1 files changed, 13 insertions, 16 deletions
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) {