Skip to content

Commit

Permalink
v1.2.6: fix
Browse files Browse the repository at this point in the history
  • Loading branch information
mizuki1412 committed Mar 4, 2022
1 parent e56f92c commit 4a90952
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ toolkit for golang projects
## 可替换的函数目录

# TODO
- [ ] https://github.com/gin-contrib/sessions/pull/148
- [ ] https://github.com/gin-contrib/sessions/pull/148 等官方更新
15 changes: 10 additions & 5 deletions mod/user/action/user/user_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,9 @@ func updatePwd(ctx *context.Context) {
panic(exception.New("用户不存在"))
}
if user.Pwd.String != cryptokit.MD5(params.OldPwd) {
panic(exception.New("密码错误"))
panic(exception.New("原密码错误"))
}
user.Pwd.String = cryptokit.MD5(params.NewPwd)
user.Pwd.Set(cryptokit.MD5(params.NewPwd))
usermapper.Update(user)
ctx.SessionSetUser(user)
ctx.SessionSave()
Expand All @@ -168,7 +168,8 @@ type updateUserInfoParam struct {
Gender int8
Image class.String
Address class.String
Pwd class.String
OldPwd class.String
NewPwd class.String
ExtendJson class.MapString
}

Expand Down Expand Up @@ -206,8 +207,12 @@ func updateUserInfo(ctx *context.Context) {
if params.ExtendJson.Valid {
u.Extend.PutAll(params.ExtendJson.Map)
}
if params.Pwd.Valid && params.Pwd.String != "" {
u.Pwd.Set(cryptokit.MD5(params.Pwd.String))
if params.OldPwd.Valid && params.NewPwd.Valid && params.OldPwd.String != "" && params.NewPwd.String != "" {
user := dao.FindById(u.Id)
if user.Pwd.String != cryptokit.MD5(params.OldPwd.String) {
panic(exception.New("原密码错误"))
}
user.Pwd.Set(cryptokit.MD5(params.NewPwd.String))
}
// todo usercenter
dao.Update(u)
Expand Down

0 comments on commit 4a90952

Please sign in to comment.