Merge branch 'main' of https://git.innov.energy/Innovenergy/git_trunk
This commit is contained in:
commit
6462b24dfd
|
@ -72,8 +72,8 @@ public class Controller : ControllerBase
|
|||
return installation;
|
||||
}
|
||||
|
||||
[HttpGet(nameof(GetUsersWithAccessToInstallation))]
|
||||
public ActionResult<IEnumerable<Object>> GetUsersWithAccessToInstallation(Int64 id, Token authToken)
|
||||
[HttpGet(nameof(GetUsersWithDirectAccessToInstallation))]
|
||||
public ActionResult<IEnumerable<Object>> GetUsersWithDirectAccessToInstallation(Int64 id, Token authToken)
|
||||
{
|
||||
var user = Db.GetSession(authToken)?.User;
|
||||
if (user == null)
|
||||
|
@ -84,23 +84,52 @@ public class Controller : ControllerBase
|
|||
if (installation is null || !user.HasAccessTo(installation))
|
||||
return Unauthorized();
|
||||
|
||||
var directAccess = installation
|
||||
return installation
|
||||
.UsersWithDirectAccess()
|
||||
.Where(u => u.IsDescendantOf(user));
|
||||
.Where(u => u.IsDescendantOf(user))
|
||||
.ToList();
|
||||
}
|
||||
|
||||
var inheritedAccess = installation
|
||||
[HttpGet(nameof(GetUsersWithInheritedAccessToInstallation))]
|
||||
public ActionResult<IEnumerable<Object>> GetUsersWithInheritedAccessToInstallation(Int64 id, Token authToken)
|
||||
{
|
||||
var user = Db.GetSession(authToken)?.User;
|
||||
if (user == null)
|
||||
return Unauthorized();
|
||||
|
||||
var installation = Db.GetInstallationById(id);
|
||||
|
||||
if (installation is null || !user.HasAccessTo(installation))
|
||||
return Unauthorized();
|
||||
|
||||
return installation
|
||||
.Ancestors()
|
||||
.SelectMany(f => f.UsersWithDirectAccess()
|
||||
.Where(u => u.IsDescendantOf(user))
|
||||
.Select(u => new { folderId = f.Id, user = u }));
|
||||
|
||||
return directAccess
|
||||
.Concat<Object>(inheritedAccess)
|
||||
.Apply(Ok); // TODO: typing
|
||||
.Select(u => new { folderId = f.Id, user = u }))
|
||||
.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)
|
||||
return Unauthorized();
|
||||
|
||||
var folder = Db.GetFolderById(id);
|
||||
|
||||
if (folder is null || !user.HasAccessTo(folder))
|
||||
return Unauthorized();
|
||||
|
||||
return folder
|
||||
.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)
|
||||
|
@ -113,7 +142,6 @@ public class Controller : ControllerBase
|
|||
|
||||
return folder
|
||||
.Ancestors()
|
||||
.Prepend(folder)
|
||||
.SelectMany(f => f.UsersWithDirectAccess()
|
||||
.Where(u => u.IsDescendantOf(user))
|
||||
.Select(u => new { folderId = f.Id, user = u }))
|
||||
|
@ -135,6 +163,15 @@ public class Controller : ControllerBase
|
|||
return folder;
|
||||
}
|
||||
|
||||
[HttpGet(nameof(GetAllChildUsers))]
|
||||
public ActionResult<IEnumerable<User>> GetAllChildUsers(Token authToken)
|
||||
{
|
||||
var user = Db.GetSession(authToken)?.User;
|
||||
if (user == null)
|
||||
return Unauthorized();
|
||||
|
||||
return user.ChildUsers().ToList();
|
||||
}
|
||||
|
||||
[HttpGet(nameof(GetAllInstallations))]
|
||||
public ActionResult<IEnumerable<Installation>> GetAllInstallations(Token authToken)
|
||||
|
|
Binary file not shown.
Loading…
Reference in New Issue