Skip to content

Commit

Permalink
修改密码如果没有配置短信使用配置的code验证
Browse files Browse the repository at this point in the history
  • Loading branch information
yannanfeiff authored and tangtaoit committed Aug 12, 2023
1 parent 770c725 commit 390ef2c
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions modules/user/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -2131,12 +2131,21 @@ func (u *User) pwdforget(c *wkhttp.Context) {
c.ResponseError(errors.New("该账号不存在"))
return
}
//线上验证短信验证码
err = u.smsServie.Verify(context.Background(), req.Zone, req.Phone, req.Code, commonapi.CodeTypeForgetLoginPWD)
if err != nil {
c.ResponseError(err)
return
//测试模式
if strings.TrimSpace(u.ctx.GetConfig().SMSCode) != "" {
if strings.TrimSpace(u.ctx.GetConfig().SMSCode) != req.Code {
c.ResponseError(errors.New("验证码错误"))
return
}
} else {
//线上验证短信验证码
err = u.smsServie.Verify(context.Background(), req.Zone, req.Phone, req.Code, commonapi.CodeTypeForgetLoginPWD)
if err != nil {
c.ResponseError(err)
return
}
}

err = u.db.UpdateUsersWithField("password", util.MD5(util.MD5(req.Pwd)), userInfo.UID)
if err != nil {
u.Error("修改登录密码错误", zap.Error(err))
Expand Down

0 comments on commit 390ef2c

Please sign in to comment.