作者 yangfu

1.登录验证码登录修改

... ... @@ -39,11 +39,11 @@ func (this *AuthController) SmsCode() {
}()
var request *protocol.SmsCodeRequest
if err := this.JsonUnmarshal(&request); err != nil {
msg = protocol.BadRequestParam(2)
msg = protocol.NewMesage(2)
return
}
if b, m := this.Valid(request); !b {
msg = m
if b, _ := this.Valid(request); !b {
msg = protocol.NewResponseMessage(2, "手机号码有误,请重新输入!")
return
}
msg = protocol.NewReturnResponse(auth.SmsCode(request))
... ... @@ -147,6 +147,10 @@ func (this *AuthController) AuthCheckSmsCode() {
}
header := this.GetRequestHeader(this.Ctx)
rsp, err := auth.AuthCheckSmsCode(header, request)
if err != nil {
msg = protocol.NewReturnResponse(rsp, err)
return
}
err = CacheSms.Put(request.Phone, rsp.CaptchaCertificate, 5*time.Minute)
msg = protocol.NewReturnResponse(rsp, err)
}
... ...
... ... @@ -109,6 +109,15 @@ func NewReturnResponse(data interface{}, eRR error) *ResponseMessage {
return NewMesage(1)
}
func NewResponseMessage(code int, err string) *ResponseMessage {
return &ResponseMessage{
ErrorCode: ErrorCode{
Errno: code,
Errmsg: err,
},
}
}
func BadRequestParam(code int) *ResponseMessage {
return NewMesage(code)
}
... ...