|
|
@@ -6,6 +6,7 @@ import (
|
|
|
"gorm.io/gorm"
|
|
|
"one-api/common"
|
|
|
"strings"
|
|
|
+ "time"
|
|
|
)
|
|
|
|
|
|
// User if you add sensitive fields, don't forget to clean them in setupLogin function.
|
|
|
@@ -202,9 +203,13 @@ func (user *User) Update(updatePassword bool) error {
|
|
|
}
|
|
|
}
|
|
|
newUser := *user
|
|
|
-
|
|
|
DB.First(&user, user.Id)
|
|
|
err = DB.Model(user).Updates(newUser).Error
|
|
|
+ if err == nil {
|
|
|
+ if common.RedisEnabled {
|
|
|
+ _ = common.RedisSet(fmt.Sprintf("user_group:%d", user.Id), user.Group, time.Duration(UserId2GroupCacheSeconds)*time.Second)
|
|
|
+ }
|
|
|
+ }
|
|
|
return err
|
|
|
}
|
|
|
|