sojuctl: change-password: check if user exists
When changing the password, checks if the user exists *before* prompting for a password change, instead of after.
This commit is contained in:
parent
cab0fc2b7d
commit
586c7ee336
@ -84,6 +84,11 @@ func main() {
|
|||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
user, err := db.GetUser(username)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("failed to get user: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
password, err := readPassword()
|
password, err := readPassword()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("failed to read password: %v", err)
|
log.Fatalf("failed to read password: %v", err)
|
||||||
@ -94,10 +99,6 @@ func main() {
|
|||||||
log.Fatalf("failed to hash password: %v", err)
|
log.Fatalf("failed to hash password: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
user, err := db.GetUser(username)
|
|
||||||
if err != nil {
|
|
||||||
log.Fatalf("failed to get user: %v", err)
|
|
||||||
}
|
|
||||||
user.Password = string(hashed)
|
user.Password = string(hashed)
|
||||||
if err := db.StoreUser(user); err != nil {
|
if err := db.StoreUser(user); err != nil {
|
||||||
log.Fatalf("failed to update password: %v", err)
|
log.Fatalf("failed to update password: %v", err)
|
||||||
|
Loading…
Reference in New Issue
Block a user