public async Task <PasswordAdto> ChangePasswordAsync(ChangePasswordAdto changePasswordAdto) { using (ITransaction transaction = _transactionManager.Create()) { try { Identity identity = await _identityCommandRepository.GetWithConcurrencyCheckAsync(changePasswordAdto.IdentityId, changePasswordAdto.Version); if (identity == null) { throw new BusinessApplicationException(ExceptionType.NotFound, "Identity does not exist"); } await _changePasswordCommand.ExecuteAsync(identity, new ChangePasswordCommandDdto { Password = changePasswordAdto.Password, ConfirmPassword = changePasswordAdto.ConfirmPassword }); await _identityCommandRepository.UpdateAsync(identity); transaction.Commit(); return(new PasswordAdto { IdentityId = identity.Id }); } catch (PasswordNotSetDomainException e) { throw new BusinessApplicationException(ExceptionType.NotFound, e); } catch (ConcurrencyDomainException e) { throw new BusinessApplicationException(ExceptionType.Concurrency, e); } catch (DomainValidationRuleException e) { throw new BusinessValidationRuleApplicationException(e.ValidationResult); } catch (NotFoundDomainException e) { throw new BusinessApplicationException(ExceptionType.NotFound, e); } } }
public Task <PasswordAdto> ChangePasswordAsync(ChangePasswordAdto changePasswordAdto) { return(_securityApplicationService.SecureAsync(() => _identityApplicationService.ChangePasswordAsync(changePasswordAdto), IdentityAuthorisationContext.Create(changePasswordAdto.IdentityId, AuthorisationAction.Update))); }