summaryrefslogtreecommitdiffstats
path: root/routers/user/auth.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2017-08-12 22:18:44 +0800
committerGitHub <noreply@github.com>2017-08-12 22:18:44 +0800
commitf960e19c590d27fe62a3a6241f1ea8b7fadde13a (patch)
treecb5045491959550fad930e82434a7f6e27d33cf3 /routers/user/auth.go
parent921d90fd8b929533e30c896923cb3a6f3d33f45a (diff)
downloadgitea-f960e19c590d27fe62a3a6241f1ea8b7fadde13a.tar.gz
gitea-f960e19c590d27fe62a3a6241f1ea8b7fadde13a.zip
Only update needed columns when update user (#2296)
* only update needed columns when update user * fix missing update_unix column
Diffstat (limited to 'routers/user/auth.go')
-rw-r--r--routers/user/auth.go18
1 files changed, 10 insertions, 8 deletions
diff --git a/routers/user/auth.go b/routers/user/auth.go
index f1aa9d26a8..b2caba0bb1 100644
--- a/routers/user/auth.go
+++ b/routers/user/auth.go
@@ -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
}