作者 yangfu

auth fix

... ... @@ -16,6 +16,7 @@ var errmessge ErrorMap = map[int]string{
2025: "短信验证码验证失败",
2026: "新密码与确认密码不一致",
2027:"密码必须至少有6个字符",
2028:"请输入正确的旧密码",
4139: "authCode无效或过期",
4140: "refreshToken过期,需要重新登录授权",
4141: "accessToken过期或无效,需要进行重新获取令牌",
... ...
... ... @@ -278,7 +278,7 @@ func SmsCode(request *protocol.SmsCodeRequest) (rsp *protocol.SmsCodeResponse, e
smsInfo.Count = 0
smsInfo.CreateTime = time.Now().Unix()
}
if smsInfo.Count > protocol.SmscodeDayLimitTime { //TODO:limit send time
if smsInfo.Count >= protocol.SmscodeDayLimitTime { //TODO:limit send time
err=protocol.NewErrWithMessage(1011)
return
}
... ...
... ... @@ -68,6 +68,9 @@ func ResetPassword(header *protocol.RequestHeader, request *protocol.ResetPasswo
if !strings.EqualFold(request.NewPwd, request.ConfirmPwd) {
err = protocol.NewErrWithMessage(2026)
}
if len(request.NewPwd)<6 {
err = protocol.NewErrWithMessage(2027)
}
err = utils.UpdateTableByMap(&models.User{Id: user.Id}, map[string]interface{}{"Passwd": request.NewPwd})
return
}
... ... @@ -78,15 +81,18 @@ func ChangePassword(header *protocol.RequestHeader, request *protocol.ChangePass
user *models.User
)
//rsp =&protocol.ChangePasswordResponse{}
if !strings.EqualFold(request.NewPwd, request.ConfirmPwd) {
err = protocol.NewErrWithMessage(2026)
}
if len(request.NewPwd)<6 {
err = protocol.NewErrWithMessage(2027)
}
if user, err = repository.User.GetUsersById(header.Uid); err != nil {
log.Error(err)
return
}
if strings.EqualFold(request.OldPwd, user.Passwd) {
err = protocol.NewErrWithMessage(1)
}
if !strings.EqualFold(request.NewPwd, request.ConfirmPwd) {
err = protocol.NewErrWithMessage(2026)
if !strings.EqualFold(request.OldPwd, user.Passwd) {
err = protocol.NewErrWithMessage(2028)
}
err = utils.UpdateTableByMap(&models.User{Id: user.Id}, map[string]interface{}{"Passwd": request.NewPwd})
return
... ...