作者 yangfu

user auth fix

... ... @@ -136,8 +136,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.UserCenterLoginResponse
)
if !strings.EqualFold(request.NewPwd, request.ConfirmPwd) {
err = protocol.NewErrWithMessage(2026)
... ... @@ -155,39 +155,49 @@ func ChangePassword(header *protocol.RequestHeader, request *protocol.ChangePass
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.MethodLogin, http.MethodPost, &protocol.UCenterLoginRequest{
// PassWord: request.OldPwd,
// Phone: user.Phone,
// Type: 1,
// GrantType: protocol.LoginTypePassPord,
//}, &message); err != nil {
// 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
//}
return
}
... ...