...
|
...
|
@@ -52,20 +52,34 @@ func (srv UserService) CheckSmsCode(smsCodeCommand *command.CheckSmsCodeCommand) |
|
|
//ChangePassword 修改密码
|
|
|
func (srv UserService) ChangePassword(changePasswordCommand *command.ChangePasswordCommand) (interface{}, error) {
|
|
|
smsServeGateway := sms_serve.NewHttplibHttplibSmsServe()
|
|
|
err := smsServeGateway.CheckSmsCode(changePasswordCommand.Phone, changePasswordCommand.SmsCode)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
|
|
}
|
|
|
// 2.重置密码
|
|
|
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(domain.Operator{})
|
|
|
_, err = creationUserGateway.AuthResetPassword(allied_creation_user.ReqAuthResetPassword{
|
|
|
Phone: changePasswordCommand.Phone,
|
|
|
Password: changePasswordCommand.NewPassword,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
|
|
if len(changePasswordCommand.OldPassword) > 0 {
|
|
|
// 2.重置密码
|
|
|
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(domain.Operator{})
|
|
|
_, err := creationUserGateway.AuthChangePassword(allied_creation_user.ReqAuthChangePassword{
|
|
|
OldPassword: changePasswordCommand.OldPassword,
|
|
|
NewPassword: changePasswordCommand.NewPassword,
|
|
|
UserId: changePasswordCommand.Operator.UserId,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
|
|
}
|
|
|
} else {
|
|
|
err := smsServeGateway.CheckSmsCode(changePasswordCommand.Phone, changePasswordCommand.SmsCode)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
|
|
}
|
|
|
// 2.重置密码
|
|
|
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(domain.Operator{})
|
|
|
_, err = creationUserGateway.AuthResetPassword(allied_creation_user.ReqAuthResetPassword{
|
|
|
Phone: changePasswordCommand.Phone,
|
|
|
Password: changePasswordCommand.NewPassword,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
|
|
}
|
|
|
}
|
|
|
return changePasswordCommand, nil
|
|
|
|
|
|
return struct{}{}, nil
|
|
|
}
|
|
|
|
|
|
//ChangePhone 修改手机号
|
...
|
...
|
|