Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/06/17 16:16:01 (6 years ago)
Author:
jzenisek
Message:

#2839 worked on permission check at AddTask

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HiveProjectManagement/HeuristicLab.Services.Hive/3.3/HiveService.cs

    r15411 r15497  
    7272        var taskDao = pm.TaskDao;
    7373        var stateLogDao = pm.StateLogDao;
     74
     75        var resourceDao = pm.ResourceDao;
     76        var resourcePermissionDao = pm.ResourcePermissionDao;
     77
     78        var currentUserId = UserManager.CurrentUserId;
     79
     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();
     100
    74101        var newTask = task.ToEntity();
    75102        newTask.JobData = taskData.ToEntity();
     
    830857              || x.OwnerUserId == currentUserId
    831858              || UserManager.VerifyUser(currentUserId, resourcePermissions
    832                   .Where(y => y.ResourceId == x.ResourceId)
     859                  //.Where(y => y.ResourceId == x.ResourceId)
    833860                  .Select(z => z.GrantedUserId)
    834861                  .ToList())
     
    855882              || x.OwnerUserId == currentUserId
    856883              || UserManager.VerifyUser(currentUserId, resourcePermissions
    857                   .Where(y => y.ResourceId == x.ResourceId)
     884                  //.Where(y => y.ResourceId == x.ResourceId)
    858885                  .Select(z => z.GrantedUserId)
    859886                  .ToList())
Note: See TracChangeset for help on using the changeset viewer.