public async Task <PolicyResponseModel> Get(string orgId, int type) { var orgIdGuid = new Guid(orgId); if (!_currentContext.ManagePolicies(orgIdGuid)) { throw new NotFoundException(); } var policy = await _policyRepository.GetByOrganizationIdTypeAsync(orgIdGuid, (PolicyType)type); if (policy == null) { throw new NotFoundException(); } return(new PolicyResponseModel(policy)); }
public async Task <TwoFactorDuoResponseModel> GetOrganizationDuo(string id, [FromBody] SecretVerificationRequestModel model) { var user = await CheckAsync(model, false); var orgIdGuid = new Guid(id); if (!await _currentContext.ManagePolicies(orgIdGuid)) { throw new NotFoundException(); } var organization = await _organizationRepository.GetByIdAsync(orgIdGuid); if (organization == null) { throw new NotFoundException(); } var response = new TwoFactorDuoResponseModel(organization); return(response); }
private async Task ValidateUserCanSaveAsync(Guid?userId) { if (!userId.HasValue || (!_currentContext.Organizations?.Any() ?? true)) { return; } var policies = await _policyRepository.GetManyByUserIdAsync(userId.Value); if (policies == null) { return; } foreach (var policy in policies.Where(p => p.Enabled && p.Type == PolicyType.DisableSend)) { if (!_currentContext.ManagePolicies(policy.OrganizationId)) { throw new BadRequestException("Due to an Enterprise Policy, you are only able to delete an existing Send."); } } }