示例#1
0
        public async Task ResetPasswordAsync(ResetPasswordAdto resetPasswordAdto)
        {
            using (ITransaction transaction = _transactionManager.Create())
            {
                try
                {
                    Identity identity = await _resetPasswordCommand.ExecuteAsync(new ResetPasswordCommandDdto
                    {
                        Token           = resetPasswordAdto.Token,
                        Password        = resetPasswordAdto.Password,
                        ConfirmPassword = resetPasswordAdto.ConfirmPassword
                    });

                    await _identityCommandRepository.UpdateAsync(identity);

                    transaction.Commit();
                }
                catch (PasswordIdentityExistsDomainException)
                {
                    throw new BusinessApplicationException(ExceptionType.Conflict, "Password already set");
                }
                catch (InvalidTwoFactorTokenDomainException)
                {
                    throw new BusinessApplicationException(ExceptionType.Unauthorized, "Two factor token is not recognized");
                }
                catch (ConcurrencyDomainException e)
                {
                    throw new BusinessApplicationException(ExceptionType.Concurrency, e);
                }
                catch (DomainValidationRuleException e)
                {
                    throw new BusinessValidationRuleApplicationException(e.ValidationResult);
                }
            }
        }
 public Task ResetPasswordAsync(ResetPasswordAdto resetPasswordAdto)
 {
     return(_securityApplicationService.SecureAsync(() => _identityApplicationService.ResetPasswordAsync(resetPasswordAdto),
                                                    DefaultAuthorisationContext.Create(AuthorisationResource.Identity, AuthorisationAction.Create)));
 }