1
0
Fork 0
mirror of https://github.com/binwiederhier/ntfy.git synced 2024-12-22 17:52:30 +01:00

Moves password stdin down to the original location.

This commit is contained in:
Kenix 2022-06-20 13:24:42 -04:00
parent 1265e69eee
commit 50cd50cfdf

View file

@ -147,7 +147,13 @@ func execUserAdd(c *cli.Context) error {
} else if !auth.AllowedRole(role) {
return errors.New("role must be either 'user' or 'admin'")
}
manager, err := createAuthManager(c)
if err != nil {
return err
}
if user, _ := manager.User(username); user != nil {
return fmt.Errorf("user %s already exists", username)
}
// If the password env var was not set, read it from stdin
if password == "" {
p, err := readPasswordAndConfirm(c)
@ -157,14 +163,6 @@ func execUserAdd(c *cli.Context) error {
password = p
}
manager, err := createAuthManager(c)
if err != nil {
return err
}
if user, _ := manager.User(username); user != nil {
return fmt.Errorf("user %s already exists", username)
}
if err := manager.AddUser(username, password, role); err != nil {
return err
}