Changeset 15500 for branches/HiveProjectManagement
- Timestamp:
- 12/07/17 14:41:47 (7 years ago)
- Location:
- branches/HiveProjectManagement
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HiveProjectManagement/HeuristicLab.Services.Access/3.3/Interfaces/IUserManager.cs
r14185 r15500 31 31 MembershipUser GetUserById(Guid userId); 32 32 string GetUserNameById(Guid userId); 33 IEnumerable<Guid> GetUserGroupIdsOfUser(Guid userId); 33 34 bool VerifyUser(Guid userId, List<Guid> allowedUserGroups); 34 35 } -
branches/HiveProjectManagement/HeuristicLab.Services.Access/3.3/UserManager.cs
r14185 r15500 54 54 } 55 55 56 public IEnumerable<Guid> GetUserGroupIdsOfUser(Guid userId) { 57 using (DA.AccessServiceDataContext context = new DA.AccessServiceDataContext()) { 58 var groupIds = from g in context.UserGroupUserGroups 59 where g.UserGroupId == userId 60 select g.UserGroupUserGroupId; 61 62 var query = from g in context.UserGroupBases.OfType<DA.UserGroup>() 63 where groupIds.Contains(g.Id) 64 select g.Id; 65 66 return query.ToList(); 67 } 68 } 69 56 70 public bool VerifyUser(Guid userId, List<Guid> allowedUserGroups) { 57 71 List<DA.UserGroupUserGroup> userGroupBases; -
branches/HiveProjectManagement/HeuristicLab.Services.Hive.DataAccess/3.3/Daos/ResourcePermissionDao.cs
r15497 r15500 34 34 } 35 35 36 public IEnumerable<Guid> GetBy GrantedUserId(IEnumerable<Guid> grantedUserId) {37 string paramIds = string.Join(",", grantedUserId.Select(x => string.Format("'{0}'", x)));36 public IEnumerable<Guid> GetByUserAndGroupIds(IEnumerable<Guid> userAndGroupIds) { 37 string paramIds = string.Join(",", userAndGroupIds.Select(x => string.Format("'{0}'", x))); 38 38 if (!string.IsNullOrWhiteSpace(paramIds)) { 39 39 string query = string.Format(GetGrantedResourcesQuery, paramIds); -
branches/HiveProjectManagement/HeuristicLab.Services.Hive/3.3/HiveService.cs
r15497 r15500 75 75 var resourceDao = pm.ResourceDao; 76 76 var resourcePermissionDao = pm.ResourcePermissionDao; 77 78 77 var currentUserId = UserManager.CurrentUserId; 79 78 80 // V1 (without child check; with resourcePermission-oriented check for user grants) 81 // granted (parent) resources 82 var userGrantedResources = resourcePermissionDao.GetAll().ToList() 83 .Where(x => x.GrantedUserId == currentUserId 84 || UserManager.VerifyUser(currentUserId, new List<Guid> { x.GrantedUserId }) 85 ) 86 .Select(x => x.Resource) 87 .ToList(); 88 89 //// children 90 //var userGrantedResourceChildren = userGrantedResources 91 // .SelectMany(x => resourceDao.GetResourcesByParentId(x.ResourceId)); 92 //// join parent and child resources 93 //userGrantedResources.AddRange(userGrantedResourceChildren); 94 95 var userGrantedResourceIds = resourceIds 96 .Where(x => userGrantedResources 97 .Select(y => y.ResourceId) 98 .Contains(x)) 99 .Distinct().ToList(); 79 //// V1 user grant check 80 //// get granted (parent) resources 81 //var userGrantedResourceIds = pm.UseTransaction(() => { 82 // return resourcePermissionDao.GetAll().ToList() 83 // .Where(x => x.GrantedUserId == currentUserId 84 // || UserManager.VerifyUser(currentUserId, new List<Guid> { x.GrantedUserId })) 85 // .Select(y => y.ResourceId) 86 // .ToList(); 87 //}); 88 89 //// get children of granted parent resources 90 //var userGrantedChildResourceIds = pm.UseTransaction(() => { 91 // return userGrantedResourceIds 92 // .SelectMany(x => resourceDao.GetResourcesByParentId(x)) 93 // .Select(y => y.ResourceId); 94 //}); 95 96 //// join list of parent and child resources 97 //userGrantedResourceIds.AddRange(userGrantedChildResourceIds); 98 99 //// filter initial resourceId list with the list of the granted ones 100 //var allUserGrantedResourceIds = resourceIds 101 // .Where(x => userGrantedResourceIds.Contains(x)) 102 // .Distinct().ToList(); 103 104 // V2 user grant check 105 var allUserGrantedResourceIds = pm.UseTransaction(() => { 106 var groupAndGroupIds = new List<Guid> { currentUserId }; 107 groupAndGroupIds.AddRange(UserManager.GetUserGroupIdsOfUser(currentUserId)); 108 return resourcePermissionDao.GetByUserAndGroupIds(groupAndGroupIds); 109 }); 100 110 101 111 var newTask = task.ToEntity(); 102 112 newTask.JobData = taskData.ToEntity(); 103 113 newTask.JobData.LastUpdate = DateTime.Now; 104 newTask.AssignedTaskResources.AddRange( resourceIds.Select(114 newTask.AssignedTaskResources.AddRange(allUserGrantedResourceIds.Select( 105 115 x => new DA.AssignedTaskResource { 106 116 ResourceId = x
Note: See TracChangeset
for help on using the changeset viewer.