aboutsummaryrefslogtreecommitdiff
path: root/internal/route/user/setting.go
diff options
context:
space:
mode:
authorJoe Chen <jc@unknwon.io>2022-10-23 19:15:14 +0800
committerGitHub <noreply@github.com>2022-10-23 19:15:14 +0800
commitc58c89362161718e1079b9d43c0ce984bb1506cc (patch)
tree14a54295b60b4c2887f06bfde8b7e603e0f4d6dd /internal/route/user/setting.go
parentef0388045f8fd35a40b3404deb3caa1a37e103f7 (diff)
refactor(db): migrate password methods off `user.go` (#7205)
Diffstat (limited to 'internal/route/user/setting.go')
-rw-r--r--internal/route/user/setting.go4
1 files changed, 2 insertions, 2 deletions
diff --git a/internal/route/user/setting.go b/internal/route/user/setting.go
index aae38d60..cdb5eee2 100644
--- a/internal/route/user/setting.go
+++ b/internal/route/user/setting.go
@@ -198,7 +198,7 @@ func SettingsPasswordPost(c *context.Context, f form.ChangePassword) {
return
}
- if !c.User.ValidatePassword(f.OldPassword) {
+ if !userutil.ValidatePassword(c.User.Password, c.User.Salt, f.OldPassword) {
c.Flash.Error(c.Tr("settings.password_incorrect"))
} else if f.Password != f.Retype {
c.Flash.Error(c.Tr("form.password_not_match"))
@@ -209,7 +209,7 @@ func SettingsPasswordPost(c *context.Context, f form.ChangePassword) {
c.Errorf(err, "get user salt")
return
}
- c.User.EncodePassword()
+ c.User.Password = userutil.EncodePassword(c.User.Password, c.User.Salt)
if err := db.UpdateUser(c.User); err != nil {
c.Errorf(err, "update user")
return