Moves password stdin down to the original location.

pull/327/head
Kenix 2022-06-20 13:24:42 -04:00
parent 1265e69eee
commit 50cd50cfdf
1 changed files with 7 additions and 9 deletions

View File

@ -147,7 +147,13 @@ func execUserAdd(c *cli.Context) error {
} else if !auth.AllowedRole(role) { } else if !auth.AllowedRole(role) {
return errors.New("role must be either 'user' or 'admin'") 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 the password env var was not set, read it from stdin
if password == "" { if password == "" {
p, err := readPasswordAndConfirm(c) p, err := readPasswordAndConfirm(c)
@ -157,14 +163,6 @@ func execUserAdd(c *cli.Context) error {
password = p 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 { if err := manager.AddUser(username, password, role); err != nil {
return err return err
} }