Skip to content

Commit 287b594

Browse files
authored
Whenever the password is updated ensure that the hash algorithm is too (#13966)
`user.HashPassword` may potentially - and in fact now likely does - change the `passwd_hash_algo` therefore whenever the `passwd` is updated, this also needs to be updated. Fix #13832 Thanks @fblaese for the hint Signed-off-by: Andrew Thornton <[email protected]>
1 parent d07b8a7 commit 287b594

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

cmd/admin.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ func runChangePassword(c *cli.Context) error {
335335
}
336336
user.HashPassword(c.String("password"))
337337

338-
if err := models.UpdateUserCols(user, "passwd", "salt"); err != nil {
338+
if err := models.UpdateUserCols(user, "passwd", "passwd_hash_algo", "salt"); err != nil {
339339
return err
340340
}
341341

routers/user/auth.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1514,7 +1514,7 @@ func ResetPasswdPost(ctx *context.Context) {
15141514
}
15151515
u.HashPassword(passwd)
15161516
u.MustChangePassword = false
1517-
if err := models.UpdateUserCols(u, "must_change_password", "passwd", "rands", "salt"); err != nil {
1517+
if err := models.UpdateUserCols(u, "must_change_password", "passwd", "passwd_hash_algo", "rands", "salt"); err != nil {
15181518
ctx.ServerError("UpdateUser", err)
15191519
return
15201520
}
@@ -1590,7 +1590,7 @@ func MustChangePasswordPost(ctx *context.Context, cpt *captcha.Captcha, form aut
15901590
u.HashPassword(form.Password)
15911591
u.MustChangePassword = false
15921592

1593-
if err := models.UpdateUserCols(u, "must_change_password", "passwd", "salt"); err != nil {
1593+
if err := models.UpdateUserCols(u, "must_change_password", "passwd", "passwd_hash_algo", "salt"); err != nil {
15941594
ctx.ServerError("UpdateUser", err)
15951595
return
15961596
}

routers/user/setting/account.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func AccountPost(ctx *context.Context, form auth.ChangePasswordForm) {
6868
return
6969
}
7070
ctx.User.HashPassword(form.Password)
71-
if err := models.UpdateUserCols(ctx.User, "salt", "passwd"); err != nil {
71+
if err := models.UpdateUserCols(ctx.User, "salt", "passwd_hash_algo", "passwd"); err != nil {
7272
ctx.ServerError("UpdateUser", err)
7373
return
7474
}

0 commit comments

Comments
 (0)