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)
|
||||
}
|
||||
|
||||
user := soju.User{
|
||||
Created: true,
|
||||
Username: username,
|
||||
Password: string(hashed),
|
||||
user, err := db.GetUser(username)
|
||||
if err != nil {
|
||||
log.Fatalf("failed to get user: %v", err)
|
||||
}
|
||||
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)
|
||||
}
|
||||
default:
|
||||
|
Loading…
Reference in New Issue
Block a user