From c58c89362161718e1079b9d43c0ce984bb1506cc Mon Sep 17 00:00:00 2001 From: Joe Chen Date: Sun, 23 Oct 2022 19:15:14 +0800 Subject: refactor(db): migrate password methods off `user.go` (#7205) --- internal/route/user/setting.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'internal/route/user/setting.go') 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 -- cgit v1.2.3