Esempio n. 1
0
        protected override PermissionResult CanAdd(WebHook value)
        {
            if (String.IsNullOrEmpty(value.Url) || value.EventTypes.Length == 0)
            {
                return(PermissionResult.Deny);
            }

            if (String.IsNullOrEmpty(value.ProjectId) && String.IsNullOrEmpty(value.OrganizationId))
            {
                return(PermissionResult.Deny);
            }

            Project project = null;

            if (!String.IsNullOrEmpty(value.ProjectId))
            {
                project = _projectRepository.GetById(value.ProjectId, true);
                if (!IsInProject(project))
                {
                    return(PermissionResult.DenyWithMessage("Invalid project id specified."));
                }
            }

            if (!String.IsNullOrEmpty(value.OrganizationId) && !IsInOrganization(value.OrganizationId))
            {
                return(PermissionResult.DenyWithMessage("Invalid organization id specified."));
            }

            if (!_billingManager.HasPremiumFeatures(project != null ? project.OrganizationId : value.OrganizationId))
            {
                return(PermissionResult.DenyWithPlanLimitReached("Please upgrade your plan to add integrations."));
            }

            return(PermissionResult.Allow);
        }
Esempio n. 2
0
    protected override async Task <PermissionResult> CanAddAsync(Project value)
    {
        if (String.IsNullOrEmpty(value.Name))
        {
            return(PermissionResult.DenyWithMessage("Project name is required."));
        }

        if (!await IsProjectNameAvailableInternalAsync(value.OrganizationId, value.Name))
        {
            return(PermissionResult.DenyWithMessage("A project with this name already exists."));
        }

        if (!await _billingManager.CanAddProjectAsync(value))
        {
            return(PermissionResult.DenyWithPlanLimitReached("Please upgrade your plan to add additional projects."));
        }

        return(await base.CanAddAsync(value));
    }
    protected override async Task <PermissionResult> CanAddAsync(Organization value)
    {
        if (String.IsNullOrEmpty(value.Name))
        {
            return(PermissionResult.DenyWithMessage("Organization name is required."));
        }

        if (!await IsOrganizationNameAvailableInternalAsync(value.Name))
        {
            return(PermissionResult.DenyWithMessage("A organization with this name already exists."));
        }

        if (!await _billingManager.CanAddOrganizationAsync(CurrentUser))
        {
            return(PermissionResult.DenyWithPlanLimitReached("Please upgrade your plan to add an additional organization."));
        }

        return(await base.CanAddAsync(value));
    }
        protected override PermissionResult CanAdd(WebHook value)
        {
            if (String.IsNullOrEmpty(value.ProjectId) || String.IsNullOrEmpty(value.Url) || value.EventTypes.Length == 0)
            {
                return(PermissionResult.Deny);
            }

            Project project = _projectRepository.GetById(value.ProjectId, true);

            if (!IsInProject(project))
            {
                return(PermissionResult.Deny);
            }

            if (!_billingManager.CanAddIntegration(project))
            {
                return(PermissionResult.DenyWithPlanLimitReached("Please upgrade your plan to add integrations."));
            }

            return(base.CanAdd(value));
        }
        protected override async Task <PermissionResult> CanAddAsync(WebHook value)
        {
            if (String.IsNullOrEmpty(value.Url) || value.EventTypes.Length == 0)
            {
                return(PermissionResult.Deny);
            }

            if (String.IsNullOrEmpty(value.ProjectId) && String.IsNullOrEmpty(value.OrganizationId))
            {
                return(PermissionResult.Deny);
            }

            if (!String.IsNullOrEmpty(value.OrganizationId) && !IsInOrganization(value.OrganizationId))
            {
                return(PermissionResult.DenyWithMessage("Invalid organization id specified."));
            }

            Project project = null;

            if (!String.IsNullOrEmpty(value.ProjectId))
            {
                project = await GetProjectAsync(value.ProjectId);

                if (project == null)
                {
                    return(PermissionResult.DenyWithMessage("Invalid project id specified."));
                }

                value.OrganizationId = project.OrganizationId;
            }

            if (!await _billingManager.HasPremiumFeaturesAsync(project != null ? project.OrganizationId : value.OrganizationId))
            {
                return(PermissionResult.DenyWithPlanLimitReached("Please upgrade your plan to add integrations."));
            }

            return(PermissionResult.Allow);
        }