mirror of
https://github.com/linux-do/new-api.git
synced 2025-09-18 00:16:37 +08:00
fix: update user (#230)
This commit is contained in:
parent
16b9aacb06
commit
2bf404507f
@ -253,14 +253,17 @@ func (user *User) Edit(updatePassword bool) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
newUser := *user
|
newUser := *user
|
||||||
DB.First(&user, user.Id)
|
updates := map[string]interface{}{
|
||||||
err = DB.Model(user).Updates(map[string]interface{}{
|
|
||||||
"username": newUser.Username,
|
"username": newUser.Username,
|
||||||
"password": newUser.Password,
|
|
||||||
"display_name": newUser.DisplayName,
|
"display_name": newUser.DisplayName,
|
||||||
"group": newUser.Group,
|
"group": newUser.Group,
|
||||||
"quota": newUser.Quota,
|
"quota": newUser.Quota,
|
||||||
}).Error
|
}
|
||||||
|
if updatePassword {
|
||||||
|
updates["password"] = newUser.Password
|
||||||
|
}
|
||||||
|
DB.First(&user, user.Id)
|
||||||
|
err = DB.Model(user).Updates(updates).Error
|
||||||
if err == nil {
|
if err == nil {
|
||||||
if common.RedisEnabled {
|
if common.RedisEnabled {
|
||||||
_ = common.RedisSet(fmt.Sprintf("user_group:%d", user.Id), user.Group, time.Duration(UserId2GroupCacheSeconds)*time.Second)
|
_ = common.RedisSet(fmt.Sprintf("user_group:%d", user.Id), user.Group, time.Duration(UserId2GroupCacheSeconds)*time.Second)
|
||||||
|
Loading…
Reference in New Issue
Block a user