Ejemplo n.º 1
0
        public async Task ConfirmIdentityAsync(ConfirmIdentityAdto confirmIdentityAdto)
        {
            using (ITransaction transaction = _transactionManager.Create())
            {
                try
                {
                    Identity identity = await _identityCommandRepository.GetByIdAsync(confirmIdentityAdto.IdentityId);

                    if (identity == null)
                    {
                        throw new BusinessApplicationException(ExceptionType.NotFound, "No identity found to confirm identity");
                    }

                    await _confirmIdentityCommand.ExecuteAsync(identity, new ConfirmIdentityCommandDdto
                    {
                        Token = confirmIdentityAdto.Token
                    });

                    await _identityCommandRepository.UpdateAsync(identity);

                    transaction.Commit();
                }
                catch (InvalidTwoFactorTokenDomainException)
                {
                    throw new BusinessApplicationException(ExceptionType.Unauthorized, "Token invalid for identity");
                }
                catch (DomainValidationRuleException e)
                {
                    throw new BusinessValidationRuleApplicationException(e.ValidationResult);
                }
            }
        }
 public Task ConfirmIdentityAsync(ConfirmIdentityAdto confirmIdentityAdto)
 {
     return(_securityApplicationService.SecureAsync(() => _identityApplicationService.ConfirmIdentityAsync(confirmIdentityAdto),
                                                    IdentityAuthorisationContext.Create(confirmIdentityAdto.IdentityId, IdentityAuthorisationAction.Confirm)));
 }