作者 yangfu

auth fix

@@ -16,6 +16,7 @@ var errmessge ErrorMap = map[int]string{ @@ -16,6 +16,7 @@ var errmessge ErrorMap = map[int]string{
16 2025: "短信验证码验证失败", 16 2025: "短信验证码验证失败",
17 2026: "新密码与确认密码不一致", 17 2026: "新密码与确认密码不一致",
18 2027:"密码必须至少有6个字符", 18 2027:"密码必须至少有6个字符",
  19 + 2028:"请输入正确的旧密码",
19 4139: "authCode无效或过期", 20 4139: "authCode无效或过期",
20 4140: "refreshToken过期,需要重新登录授权", 21 4140: "refreshToken过期,需要重新登录授权",
21 4141: "accessToken过期或无效,需要进行重新获取令牌", 22 4141: "accessToken过期或无效,需要进行重新获取令牌",
@@ -278,7 +278,7 @@ func SmsCode(request *protocol.SmsCodeRequest) (rsp *protocol.SmsCodeResponse, e @@ -278,7 +278,7 @@ func SmsCode(request *protocol.SmsCodeRequest) (rsp *protocol.SmsCodeResponse, e
278 smsInfo.Count = 0 278 smsInfo.Count = 0
279 smsInfo.CreateTime = time.Now().Unix() 279 smsInfo.CreateTime = time.Now().Unix()
280 } 280 }
281 - if smsInfo.Count > protocol.SmscodeDayLimitTime { //TODO:limit send time 281 + if smsInfo.Count >= protocol.SmscodeDayLimitTime { //TODO:limit send time
282 err=protocol.NewErrWithMessage(1011) 282 err=protocol.NewErrWithMessage(1011)
283 return 283 return
284 } 284 }
@@ -68,6 +68,9 @@ func ResetPassword(header *protocol.RequestHeader, request *protocol.ResetPasswo @@ -68,6 +68,9 @@ func ResetPassword(header *protocol.RequestHeader, request *protocol.ResetPasswo
68 if !strings.EqualFold(request.NewPwd, request.ConfirmPwd) { 68 if !strings.EqualFold(request.NewPwd, request.ConfirmPwd) {
69 err = protocol.NewErrWithMessage(2026) 69 err = protocol.NewErrWithMessage(2026)
70 } 70 }
  71 + if len(request.NewPwd)<6 {
  72 + err = protocol.NewErrWithMessage(2027)
  73 + }
71 err = utils.UpdateTableByMap(&models.User{Id: user.Id}, map[string]interface{}{"Passwd": request.NewPwd}) 74 err = utils.UpdateTableByMap(&models.User{Id: user.Id}, map[string]interface{}{"Passwd": request.NewPwd})
72 return 75 return
73 } 76 }
@@ -78,15 +81,18 @@ func ChangePassword(header *protocol.RequestHeader, request *protocol.ChangePass @@ -78,15 +81,18 @@ func ChangePassword(header *protocol.RequestHeader, request *protocol.ChangePass
78 user *models.User 81 user *models.User
79 ) 82 )
80 //rsp =&protocol.ChangePasswordResponse{} 83 //rsp =&protocol.ChangePasswordResponse{}
  84 + if !strings.EqualFold(request.NewPwd, request.ConfirmPwd) {
  85 + err = protocol.NewErrWithMessage(2026)
  86 + }
  87 + if len(request.NewPwd)<6 {
  88 + err = protocol.NewErrWithMessage(2027)
  89 + }
81 if user, err = repository.User.GetUsersById(header.Uid); err != nil { 90 if user, err = repository.User.GetUsersById(header.Uid); err != nil {
82 log.Error(err) 91 log.Error(err)
83 return 92 return
84 } 93 }
85 - if strings.EqualFold(request.OldPwd, user.Passwd) {  
86 - err = protocol.NewErrWithMessage(1)  
87 - }  
88 - if !strings.EqualFold(request.NewPwd, request.ConfirmPwd) {  
89 - err = protocol.NewErrWithMessage(2026) 94 + if !strings.EqualFold(request.OldPwd, user.Passwd) {
  95 + err = protocol.NewErrWithMessage(2028)
90 } 96 }
91 err = utils.UpdateTableByMap(&models.User{Id: user.Id}, map[string]interface{}{"Passwd": request.NewPwd}) 97 err = utils.UpdateTableByMap(&models.User{Id: user.Id}, map[string]interface{}{"Passwd": request.NewPwd})
92 return 98 return