...
|
...
|
@@ -114,10 +114,30 @@ func (authService *AuthService) PhoneAuthCheck(phoneAuthCheckCommand *command.Ph |
|
|
defer func() {
|
|
|
transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
|
|
|
var userBaseRepository domain.UserBaseRepository
|
|
|
if value, err := factory.CreateUserBaseRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
}); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
userBaseRepository = value
|
|
|
}
|
|
|
userBase, err := userBaseRepository.FindOne(map[string]interface{}{"account": phoneAuthCheckCommand.Phone})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
if err == domain.ErrorNotFound {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, "该用户不存在")
|
|
|
}
|
|
|
if err := userBase.CheckAccountPassword(phoneAuthCheckCommand.Phone, phoneAuthCheckCommand.Password); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
return nil, nil
|
|
|
return struct{}{}, nil
|
|
|
}
|
|
|
|
|
|
// 重置密码(忘记密码)
|
...
|
...
|
@@ -135,10 +155,34 @@ func (authService *AuthService) PhoneAuthResetPassword(phoneAuthResetPasswordCom |
|
|
defer func() {
|
|
|
transactionContext.RollbackTransaction()
|
|
|
}()
|
|
|
|
|
|
var userBaseRepository domain.UserBaseRepository
|
|
|
if value, err := factory.CreateUserBaseRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
}); err != nil {
|
|
|
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
} else {
|
|
|
userBaseRepository = value
|
|
|
}
|
|
|
userBase, err := userBaseRepository.FindOne(map[string]interface{}{"account": phoneAuthResetPasswordCommand.Phone})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
if err == domain.ErrorNotFound {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, "该用户不存在")
|
|
|
}
|
|
|
if err := userBase.ResetPassword(phoneAuthResetPasswordCommand.Phone, phoneAuthResetPasswordCommand.Password); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
|
|
|
if _, err = userBaseRepository.Save(userBase); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
|
|
|
if err := transactionContext.CommitTransaction(); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
return nil, nil
|
|
|
return struct{}{}, nil
|
|
|
}
|
|
|
|
|
|
// 重置手机号
|
...
|
...
|
|