split users with direct and inherited access to folders call
This commit is contained in:
parent
c751cb8e8f
commit
656b671962
|
@ -110,8 +110,8 @@ public class Controller : ControllerBase
|
|||
.ToList();
|
||||
}
|
||||
|
||||
[HttpGet(nameof(GetUsersWithAccessToFolder))]
|
||||
public ActionResult<IEnumerable<Object>> GetUsersWithAccessToFolder(Int64 id, Token authToken)
|
||||
[HttpGet(nameof(GetUsersWithDirectAccessToFolder))]
|
||||
public ActionResult<IEnumerable<Object>> GetUsersWithDirectAccessToFolder(Int64 id, Token authToken)
|
||||
{
|
||||
var user = Db.GetSession(authToken)?.User;
|
||||
if (user == null)
|
||||
|
@ -123,12 +123,29 @@ public class Controller : ControllerBase
|
|||
return Unauthorized();
|
||||
|
||||
return folder
|
||||
.Ancestors()
|
||||
.Prepend(folder)
|
||||
.SelectMany(f => f.UsersWithDirectAccess()
|
||||
.Where(u => u.IsDescendantOf(user))
|
||||
.Select(u => new { folderId = f.Id, user = u }))
|
||||
.ToList();
|
||||
.UsersWithDirectAccess()
|
||||
.Where(u => u.IsDescendantOf(user))
|
||||
.ToList();
|
||||
}
|
||||
|
||||
[HttpGet(nameof(GetUsersWithInheritedAccessToFolder))]
|
||||
public ActionResult<IEnumerable<Object>> GetUsersWithInheritedAccessToFolder(Int64 id, Token authToken)
|
||||
{
|
||||
var user = Db.GetSession(authToken)?.User;
|
||||
if (user == null)
|
||||
return Unauthorized();
|
||||
|
||||
var folder = Db.GetFolderById(id);
|
||||
|
||||
if (folder is null || !user.HasAccessTo(folder))
|
||||
return Unauthorized();
|
||||
|
||||
return folder
|
||||
.Ancestors()
|
||||
.SelectMany(f => f.UsersWithDirectAccess()
|
||||
.Where(u => u.IsDescendantOf(user))
|
||||
.Select(u => new { folderId = f.Id, user = u }))
|
||||
.ToList();
|
||||
}
|
||||
|
||||
[HttpGet(nameof(GetFolderById))]
|
||||
|
|
Loading…
Reference in New Issue