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:
parent
1265e69eee
commit
50cd50cfdf
1 changed files with 7 additions and 9 deletions
16
cmd/user.go
16
cmd/user.go
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue