1
0
Fork 0
mirror of https://github.com/binwiederhier/ntfy.git synced 2025-06-09 06:24:44 +02:00

More polishing, more docs; the only thing left are tests for access.go

This commit is contained in:
Philipp Heckel 2022-02-03 20:20:50 -05:00
parent d714af43c9
commit 4972407145
3 changed files with 25 additions and 19 deletions

View file

@ -144,7 +144,7 @@ func execUserAdd(c *cli.Context) error {
if user, _ := manager.User(username); user != nil {
return fmt.Errorf("user %s already exists", username)
}
password, err := readPassword(c)
password, err := readPasswordAndConfirm(c)
if err != nil {
return err
}
@ -190,7 +190,7 @@ func execUserChangePass(c *cli.Context) error {
if _, err := manager.User(username); err == auth.ErrNotFound {
return fmt.Errorf("user %s does not exist", username)
}
password, err := readPassword(c)
password, err := readPasswordAndConfirm(c)
if err != nil {
return err
}
@ -250,13 +250,13 @@ func createAuthManager(c *cli.Context) (auth.Manager, error) {
return auth.NewSQLiteAuth(authFile, authDefaultRead, authDefaultWrite)
}
func readPassword(c *cli.Context) (string, error) {
fmt.Fprint(c.App.ErrWriter, "Enter Password: ")
func readPasswordAndConfirm(c *cli.Context) (string, error) {
fmt.Fprint(c.App.ErrWriter, "password: ")
password, err := util.ReadPassword(c.App.Reader)
if err != nil {
return "", err
}
fmt.Fprintf(c.App.ErrWriter, "\r%s\rConfirm: ", strings.Repeat(" ", 25))
fmt.Fprintf(c.App.ErrWriter, "\r%s\rconfirm: ", strings.Repeat(" ", 25))
confirm, err := util.ReadPassword(c.App.Reader)
if err != nil {
return "", err