cmd/sojuctl: read user from DB before updating it
This makes sure we don't overwrite other fields, such as Admin. Closes: https://todo.sr.ht/~emersion/soju/85
This commit is contained in:
parent
ccc8768435
commit
c1f8002428
@ -94,12 +94,12 @@ func main() {
|
|||||||
log.Fatalf("failed to hash password: %v", err)
|
log.Fatalf("failed to hash password: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
user := soju.User{
|
user, err := db.GetUser(username)
|
||||||
Created: true,
|
if err != nil {
|
||||||
Username: username,
|
log.Fatalf("failed to get user: %v", err)
|
||||||
Password: string(hashed),
|
|
||||||
}
|
}
|
||||||
if err := db.StoreUser(&user); err != nil {
|
user.Password = string(hashed)
|
||||||
|
if err := db.StoreUser(user); err != nil {
|
||||||
log.Fatalf("failed to update password: %v", err)
|
log.Fatalf("failed to update password: %v", err)
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
Loading…
Reference in New Issue
Block a user