implement GrantUserAccessTo for folders and installations
This commit is contained in:
parent
2cb3701fae
commit
4c87fcb5ea
|
@ -110,6 +110,34 @@ public static class SessionMethods
|
|||
&& Db.Delete(userToDelete);
|
||||
}
|
||||
|
||||
|
||||
public static Boolean GrantUserAccessTo(this Session? session, User? user, Installation? installation)
|
||||
{
|
||||
var sessionUser = session?.User;
|
||||
|
||||
return sessionUser is not null
|
||||
&& user is not null
|
||||
&& installation is not null
|
||||
&& user.IsDescendantOf(sessionUser)
|
||||
&& sessionUser.HasAccessTo(installation)
|
||||
&& !user.HasAccessTo(installation)
|
||||
&& Db.Create(new InstallationAccess { UserId = user.Id, InstallationId = installation.Id });
|
||||
|
||||
}
|
||||
|
||||
public static Boolean GrantUserAccessTo(this Session? session, User? user, Folder? folder)
|
||||
{
|
||||
var sessionUser = session?.User;
|
||||
|
||||
return sessionUser is not null
|
||||
&& user is not null
|
||||
&& folder is not null
|
||||
&& user.IsDescendantOf(sessionUser)
|
||||
&& sessionUser.HasAccessTo(folder)
|
||||
&& !user.HasAccessTo(folder)
|
||||
&& Db.Create(new FolderAccess { UserId = user.Id, FolderId = folder.Id });
|
||||
}
|
||||
|
||||
public static Boolean Logout(this Session? session)
|
||||
{
|
||||
return session is not null
|
||||
|
|
Loading…
Reference in New Issue