diff --git a/csharp/App/Backend/DataTypes/Methods/Session.cs b/csharp/App/Backend/DataTypes/Methods/Session.cs index fc66f90d1..86960dab2 100644 --- a/csharp/App/Backend/DataTypes/Methods/Session.cs +++ b/csharp/App/Backend/DataTypes/Methods/Session.cs @@ -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