...
|
...
|
@@ -2,9 +2,11 @@ package controllers |
|
|
|
|
|
import (
|
|
|
"fmt"
|
|
|
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/application/auth"
|
|
|
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/application/user"
|
|
|
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/protocol"
|
|
|
"strings"
|
|
|
"time"
|
|
|
)
|
|
|
|
|
|
type UserController struct {
|
...
|
...
|
@@ -61,10 +63,15 @@ func (this *UserController) CheckSmsCode() { |
|
|
**/
|
|
|
func (this *UserController) ChangePhone() {
|
|
|
var msg *protocol.ResponseMessage
|
|
|
|
|
|
defer func() {
|
|
|
this.Resp(msg)
|
|
|
}()
|
|
|
|
|
|
var request *protocol.ChangePhoneRequest
|
|
|
|
|
|
header := this.GetRequestHeader(this.Ctx)
|
|
|
|
|
|
if err := this.JsonUnmarshal(&request); err != nil {
|
|
|
msg = protocol.BadRequestParam(1)
|
|
|
return
|
...
|
...
|
@@ -73,21 +80,42 @@ func (this *UserController) ChangePhone() { |
|
|
msg = m
|
|
|
return
|
|
|
}
|
|
|
if !CacheSms.IsExist(request.OldPhone) {
|
|
|
|
|
|
// 校验短信验证码
|
|
|
var authCheckSmsCodeRequest *protocol.AuthCheckSmsCodeRequest
|
|
|
if err := this.JsonUnmarshal(&authCheckSmsCodeRequest); err != nil {
|
|
|
msg = protocol.BadRequestParam(1)
|
|
|
return
|
|
|
}
|
|
|
if b, m := this.Valid(authCheckSmsCodeRequest); !b {
|
|
|
msg = m
|
|
|
return
|
|
|
}
|
|
|
rsp, err := auth.AuthCheckSmsCode(header, authCheckSmsCodeRequest)
|
|
|
if err != nil {
|
|
|
msg = protocol.NewReturnResponse(rsp, err)
|
|
|
return
|
|
|
}
|
|
|
err = CacheSms.Put(request.Phone, rsp.CaptchaCertificate, 5*time.Minute)
|
|
|
if err != nil {
|
|
|
msg = protocol.NewReturnResponse(rsp, err)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
if !CacheSms.IsExist(request.Phone) {
|
|
|
msg = protocol.NewMesage(1009) //验证码失效
|
|
|
return
|
|
|
}
|
|
|
// TODO ?
|
|
|
//if v := CacheSms.Get(request.OldPhone); v != nil {
|
|
|
// if !strings.EqualFold(fmt.Sprintf("%v", v), strings.TrimSpace(request.CaptchaCertificate)) {
|
|
|
if v := CacheSms.Get(request.Phone); v != nil {
|
|
|
//if !strings.EqualFold(fmt.Sprintf("%v", v), strings.TrimSpace(request.CaptchaCertificate)) {
|
|
|
// msg = protocol.NewMesage(1012) //验证码不一致
|
|
|
// return
|
|
|
// }
|
|
|
//} else {
|
|
|
// msg = protocol.NewMesage(1009) //验证码不一致
|
|
|
// return
|
|
|
//}
|
|
|
header := this.GetRequestHeader(this.Ctx)
|
|
|
} else {
|
|
|
msg = protocol.NewMesage(1009) //验证码不一致
|
|
|
return
|
|
|
}
|
|
|
|
|
|
data, err := user.ChangePhone(header, request)
|
|
|
if err == nil {
|
|
|
msg = protocol.NewResponseMessage(0, "修改手机号成功")
|
...
|
...
|
|