...
|
...
|
@@ -5,6 +5,7 @@ import ( |
|
|
"github.com/astaxie/beego/orm"
|
|
|
"gitlab.fjmaimaimai.com/mmm-go/gocomm/identity/uid"
|
|
|
"gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log"
|
|
|
"net/http"
|
|
|
"opp/internal/utils"
|
|
|
"opp/models"
|
|
|
"opp/protocol"
|
...
|
...
|
@@ -46,7 +47,11 @@ func ChangePhone(header *protocol.RequestHeader, request *protocol.ChangePhoneRe |
|
|
log.Error(err)
|
|
|
return
|
|
|
}
|
|
|
if result, err = auth.CheckSmsCode(user.Phone, request.Captcha, protocol.SmsCode); err != nil {
|
|
|
if result, err = auth.CheckSmsCode(strings.TrimSpace(user.Phone), "", protocol.SmsCode); err != nil {
|
|
|
log.Error(err)
|
|
|
return
|
|
|
}
|
|
|
if result, err = auth.CheckSmsCode(request.Phone, request.Captcha, protocol.SmsCode); err != nil {
|
|
|
log.Error(err)
|
|
|
return
|
|
|
}
|
...
|
...
|
@@ -142,8 +147,8 @@ func ResetPassword(header *protocol.RequestHeader, request *protocol.ResetPasswo |
|
|
//修改密码
|
|
|
func ChangePassword(header *protocol.RequestHeader, request *protocol.ChangePasswordRequest) (rsp *protocol.ChangePasswordResponse, err error) {
|
|
|
var (
|
|
|
user *models.User
|
|
|
//loginResponse *protocol.UserCenterLoginResponse
|
|
|
user *models.User
|
|
|
loginResponse *protocol.UCenterGetUserResponse //UserCenterLoginResponse
|
|
|
)
|
|
|
if !strings.EqualFold(request.NewPwd, request.ConfirmPwd) {
|
|
|
err = protocol.NewErrWithMessage(2026)
|
...
|
...
|
@@ -161,49 +166,54 @@ func ChangePassword(header *protocol.RequestHeader, request *protocol.ChangePass |
|
|
log.Error(err)
|
|
|
return
|
|
|
}
|
|
|
err = agg.ChangeUcenterUserInfo(user.UserCenterId, user.Phone, &protocol.UCenterPutUserRequest{
|
|
|
PassWord: request.NewPwd,
|
|
|
//Phone:user.Phone,
|
|
|
})
|
|
|
log.Debug(fmt.Sprintf("修改密码 simnum:%v ucenter_id:%v pwd:%v", user.Phone, user.UserCenterId, request.NewPwd))
|
|
|
if err != nil {
|
|
|
err = protocol.NewErrWithMessage(1)
|
|
|
log.Error(err)
|
|
|
return
|
|
|
}
|
|
|
//var message protocol.Message
|
|
|
//if _, err = agg.RequestUserCenter(protocol.MethodLogin, http.MethodPost, &protocol.UCenterLoginRequest{
|
|
|
// PassWord: request.OldPwd,
|
|
|
// Phone: user.Phone,
|
|
|
// Type: 1,
|
|
|
// GrantType: protocol.LoginTypePassPord,
|
|
|
//}, &message); err != nil {
|
|
|
//err = agg.ChangeUcenterUserInfo(user.UserCenterId, user.Phone, &protocol.UCenterPutUserRequest{
|
|
|
// PassWord: request.NewPwd,
|
|
|
// //Phone:user.Phone,
|
|
|
//})
|
|
|
//log.Debug(fmt.Sprintf("修改密码 simnum:%v ucenter_id:%v pwd:%v", user.Phone, user.UserCenterId, request.NewPwd))
|
|
|
//if err != nil {
|
|
|
// err = protocol.NewErrWithMessage(1)
|
|
|
// log.Error(err)
|
|
|
// return
|
|
|
//}
|
|
|
//if message.Errno == 0 && message.Errmsg == "ok" {
|
|
|
// if err = message.Unmarshal(&loginResponse); err != nil {
|
|
|
// log.Error(err)
|
|
|
// return
|
|
|
// }
|
|
|
// if loginResponse.Id != user.UserCenterId {
|
|
|
// log.Error(fmt.Sprintf("用户中心uid不一致 input:%v want:%v", loginResponse.Id, user.UserCenterId))
|
|
|
// err = protocol.NewErrWithMessage(1)
|
|
|
// return
|
|
|
// }
|
|
|
// err = agg.ChangeUcenterUserInfo(user.UserCenterId, user.Phone, &protocol.UCenterPutUserRequest{
|
|
|
// PassWord: request.NewPwd,
|
|
|
// //Phone:user.Phone,
|
|
|
// })
|
|
|
//} else {
|
|
|
// if message.Errno == -1 {
|
|
|
// err = protocol.NewErrWithMessage(2028)
|
|
|
// } else {
|
|
|
// err = protocol.NewErrWithMessage(2028)
|
|
|
// }
|
|
|
// log.Debug(fmt.Sprintf("修改密码 simnum:%v ucenter_id:%v pwd:%v", user.Phone, user.UserCenterId, request.NewPwd), message.Errno, message.Errmsg)
|
|
|
// return
|
|
|
//}
|
|
|
var message protocol.Message
|
|
|
if _, err = agg.RequestUserCenter(protocol.MethodServerLogin, http.MethodPost, &protocol.UCenterLoginRequest{
|
|
|
PassWord: request.OldPwd,
|
|
|
Phone: user.Phone,
|
|
|
Type: 1,
|
|
|
GrantType: protocol.LoginTypePassPord,
|
|
|
}, &message); err != nil {
|
|
|
log.Error(err)
|
|
|
err = protocol.NewErrWithMessage(3)
|
|
|
return
|
|
|
}
|
|
|
if message.Errno == 0 && message.Errmsg == "ok" {
|
|
|
if err = message.Unmarshal(&loginResponse); err != nil {
|
|
|
log.Error(err)
|
|
|
return
|
|
|
}
|
|
|
if loginResponse.Id != user.UserCenterId {
|
|
|
log.Error(fmt.Sprintf("用户中心uid不一致 input:%v want:%v", loginResponse.Id, user.UserCenterId))
|
|
|
err = protocol.NewErrWithMessage(1)
|
|
|
return
|
|
|
}
|
|
|
if err = agg.ChangeUcenterUserInfo(user.UserCenterId, user.Phone, &protocol.UCenterPutUserRequest{
|
|
|
PassWord: request.NewPwd,
|
|
|
//Phone:user.Phone,
|
|
|
}); err != nil {
|
|
|
log.Error(err)
|
|
|
err = protocol.NewErrWithMessage(3)
|
|
|
return
|
|
|
}
|
|
|
} else {
|
|
|
if message.Errno == -1 {
|
|
|
err = protocol.NewErrWithMessage(2028)
|
|
|
} else {
|
|
|
err = protocol.NewErrWithMessage(3)
|
|
|
}
|
|
|
log.Debug(fmt.Sprintf("修改密码 simnum:%v ucenter_id:%v pwd:%v", user.Phone, user.UserCenterId, request.NewPwd), message.Errno, message.Errmsg)
|
|
|
return
|
|
|
}
|
|
|
return
|
|
|
}
|
|
|
|
...
|
...
|
|