mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-05-14 05:52:43 +00:00
Only update needed columns when update user (#2296)
* only update needed columns when update user * fix missing update_unix column
This commit is contained in:
parent
921d90fd8b
commit
f960e19c59
6 changed files with 45 additions and 17 deletions
|
@ -340,8 +340,8 @@ func handleSignInFull(ctx *context.Context, u *models.User, remember bool, obeyR
|
|||
|
||||
// Register last login
|
||||
u.SetLastLogin()
|
||||
if err := models.UpdateUser(u); err != nil {
|
||||
ctx.Handle(500, "UpdateUser", err)
|
||||
if err := models.UpdateUserCols(u, "last_login_unix"); err != nil {
|
||||
ctx.Handle(500, "UpdateUserCols", err)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -430,8 +430,8 @@ func handleOAuth2SignIn(u *models.User, gothUser goth.User, ctx *context.Context
|
|||
|
||||
// Register last login
|
||||
u.SetLastLogin()
|
||||
if err := models.UpdateUser(u); err != nil {
|
||||
ctx.Handle(500, "UpdateUser", err)
|
||||
if err := models.UpdateUserCols(u, "last_login_unix"); err != nil {
|
||||
ctx.Handle(500, "UpdateUserCols", err)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -666,7 +666,8 @@ func LinkAccountPostRegister(ctx *context.Context, cpt *captcha.Captcha, form au
|
|||
if models.CountUsers() == 1 {
|
||||
u.IsAdmin = true
|
||||
u.IsActive = true
|
||||
if err := models.UpdateUser(u); err != nil {
|
||||
u.SetLastLogin()
|
||||
if err := models.UpdateUserCols(u, "is_admin", "is_active", "last_login_unix"); err != nil {
|
||||
ctx.Handle(500, "UpdateUser", err)
|
||||
return
|
||||
}
|
||||
|
@ -781,7 +782,8 @@ func SignUpPost(ctx *context.Context, cpt *captcha.Captcha, form auth.RegisterFo
|
|||
if models.CountUsers() == 1 {
|
||||
u.IsAdmin = true
|
||||
u.IsActive = true
|
||||
if err := models.UpdateUser(u); err != nil {
|
||||
u.SetLastLogin()
|
||||
if err := models.UpdateUserCols(u, "is_admin", "is_active", "last_login_unix"); err != nil {
|
||||
ctx.Handle(500, "UpdateUser", err)
|
||||
return
|
||||
}
|
||||
|
@ -840,7 +842,7 @@ func Activate(ctx *context.Context) {
|
|||
ctx.Handle(500, "UpdateUser", err)
|
||||
return
|
||||
}
|
||||
if err := models.UpdateUser(user); err != nil {
|
||||
if err := models.UpdateUserCols(user, "is_active", "rands"); err != nil {
|
||||
if models.IsErrUserNotExist(err) {
|
||||
ctx.Error(404)
|
||||
} else {
|
||||
|
@ -991,7 +993,7 @@ func ResetPasswdPost(ctx *context.Context) {
|
|||
return
|
||||
}
|
||||
u.EncodePasswd()
|
||||
if err := models.UpdateUser(u); err != nil {
|
||||
if err := models.UpdateUserCols(u, "passwd", "rands", "salt"); err != nil {
|
||||
ctx.Handle(500, "UpdateUser", err)
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue