Moves password stdin down to the original location.
parent
1265e69eee
commit
50cd50cfdf
16
cmd/user.go
16
cmd/user.go
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue