Exemple #1
0
        protected override PermissionResult CanAdd(Token value)
        {
            if (String.IsNullOrEmpty(value.OrganizationId))
            {
                return(PermissionResult.DenyWithResult(BadRequest()));
            }

            if (value.Scopes.Contains("admin") && !User.IsInRole(AuthorizationRoles.GlobalAdmin))
            {
                return(PermissionResult.DenyWithResult(BadRequest()));
            }

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

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

            if (!String.IsNullOrEmpty(value.ApplicationId))
            {
                var application = _applicationRepository.GetById(value.ApplicationId, true);
                if (application == null || !IsInOrganization(application.OrganizationId))
                {
                    return(PermissionResult.DenyWithResult(BadRequest()));
                }
            }

            return(base.CanAdd(value));
        }
Exemple #2
0
        protected override PermissionResult CanDelete(Token value)
        {
            if (!IsInProject(value.ProjectId))
            {
                return(PermissionResult.DenyWithResult(BadRequest()));
            }

            return(base.CanDelete(value));
        }
        protected override PermissionResult CanUpdate(WebHook original, Delta <NewWebHook> changes)
        {
            if (!IsInProject(original.ProjectId))
            {
                return(PermissionResult.DenyWithResult(BadRequest()));
            }

            return(base.CanUpdate(original, changes));
        }
        protected override PermissionResult CanAdd(WebHook value)
        {
            if (String.IsNullOrEmpty(value.ProjectId))
            {
                return(PermissionResult.DenyWithResult(BadRequest()));
            }

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

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

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

            return(base.CanAdd(value));
        }