Esempio n. 1
0
        private void VerifyPermissionForCreateEditItem(BacklogItem item, Project project = null)
        {
            PermissionSets[] permissions = new PermissionSets[] { PermissionSets.SCRUM_MASTER, PermissionSets.PRODUCT_OWNER };

            if (project == null)
                project = projectsService.GetProject(item.ProjectUId);

            if (project.IsTicketProject)
                permissions = new PermissionSets[] { PermissionSets.SCRUM_MASTER, PermissionSets.PRODUCT_OWNER, PermissionSets.TEAM };

            authorizationService.VerifyPermissionAtProject(item.ProjectUId, permissions);

            if (!project.IsTicketProject && !authorizationService.IsProjectScrumMaster(item.ProjectUId) && item.SprintNumber != null)
                throw new WebFaultException<String>("Product owners can not plan items", System.Net.HttpStatusCode.BadRequest);
        }
 public bool MemberHasPermissionAtProject(string memberUId, string projectUId, PermissionSets permission)
 {
     throw new NotSupportedException();
 }
 public void VerifyPermissionAtProjectOrFactoryOwner(string projectUId, PermissionSets[] permissions)
 {
     throw new NotSupportedException();
 }
 public void VerifyUserOrPermissionAtProject(string memberUId, string projectUId, PermissionSets permission)
 {
     throw new NotSupportedException();
 }
Esempio n. 5
0
 public bool MemberHasPermissionAtProject(string memberUId, string projectUId, PermissionSets permission)
 {
     return projectsRepository.MemberHasPermissionAtProject(memberUId, projectUId, permission);
 }
Esempio n. 6
0
 public bool HasPermission(string memberUId, PermissionSets permission)
 {
     if (Memberships == null)
         return false;
     return Memberships.Any(m => m.MemberUId == memberUId && m.IsActive==true && m.Role.PermissionSet == (short)permission);
 }
        public void VerifyPermissionAtProjectOrFactoryOwner(string projectUId, PermissionSets[] permissions)
        {
            if (!authorizedTokens.ContainsKey(SignedMemberToken))
                throw new WebFaultException(System.Net.HttpStatusCode.Unauthorized);

            if (SignedMemberProfile.IsFactoryOwner)
                return;

            VerifyPermissionAtProject(projectUId, permissions);
        }
 public void VerifyUserOrPermissionAtProject(string memberUId, string projectUId, PermissionSets permission)
 {
     if (!projectsService.MemberHasPermissionAtProject(SignedMemberProfile.MemberUId, projectUId, new PermissionSets[] {  permission })
         && SignedMemberProfile.MemberUId != memberUId)
         throw new WebFaultException(System.Net.HttpStatusCode.Forbidden);
 }
        public void VerifyPermissionAtProject(string projectUId, PermissionSets[] permissions)
        {
            string token = SignedMemberToken;

            AuthorizationInfo authInfo = null;
            authorizedTokens.TryGetValue(token, out authInfo);

            if (authInfo==null)
                throw new WebFaultException(System.Net.HttpStatusCode.Unauthorized);

            string memberUId = authInfo.MemberUId;

            bool hasPermission = projectsService.MemberHasPermissionAtProject(memberUId, projectUId, permissions);
            if(!hasPermission)
                throw new WebFaultException(System.Net.HttpStatusCode.Forbidden);
        }
 public void VerifyPermissionAtProject(string projectUId, PermissionSets permission)
 {
     PermissionSets[] ps = new PermissionSets[1];
     ps[0] = permission;
     VerifyPermissionAtProject(projectUId, ps);
 }
        public bool MemberHasPermissionAtProject(string memberUId, string projectUId, PermissionSets[] permissions)
        {
            short[] permissionsS = new short[permissions.Length];
            for (int i = 0; i < permissions.Length; i++)
                permissionsS[i] = (short)permissions[i];

            using (var context = new ScrumFactoryEntities(this.connectionString)) {

                // does not make sense
                //if (context.Projects.Where(p => p.ProjectUId == projectUId && p.CreateBy == memberUId).Count() > 0)
                //    return true;

                if (context.ProjectMemberships.Where(
                        pmr => pmr.MemberUId == memberUId
                        && pmr.ProjectUId == projectUId
                        && pmr.IsActive == true
                        && permissionsS.Contains(pmr.Role.PermissionSet)).Count() > 0)
                    return true;
            }

            return false;
        }
 public bool MemberHasPermissionAtProject(string memberUId, string projectUId, PermissionSets permission)
 {
     PermissionSets[] ps = new PermissionSets[1];
     ps[0] = permission;
     return MemberHasPermissionAtProject(memberUId, projectUId, ps);
 }
 public int GetMembershipCountOf(string projectUId, PermissionSets permissionSet)
 {
     using (var context = new ScrumFactoryEntities(this.connectionString)) {
         return context.ProjectMemberships.Count(ms => ms.Role.PermissionSet == (short)permissionSet && ms.ProjectUId == projectUId);
     }
 }