From bd3a7a25792b837c5f28c7580adf132abc6f35e7 Mon Sep 17 00:00:00 2001 From: vnugent Date: Sun, 25 Feb 2024 01:11:06 -0500 Subject: Squashed commit of the following: commit 069f81fc3c87c437eceff756ddca7a4c1b58044d Author: vnugent Date: Sat Feb 24 22:33:34 2024 -0500 feat: #3 setup mode, admin signup, fixes, and contianerize! commit 97ffede9eb312fca0257afa06969d47a12703f3b Author: vnugent Date: Mon Feb 19 22:26:03 2024 -0500 feat: new account setup and invitation links commit 1c8f59bc0a1b25ce5013b0f1fc7fa73c0de415d6 Author: vnugent Date: Thu Feb 15 16:49:59 2024 -0500 feat: update packages, drag/drop link, and fix some button padding --- back-end/src/RoleHelpers.cs | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 back-end/src/RoleHelpers.cs (limited to 'back-end/src/RoleHelpers.cs') diff --git a/back-end/src/RoleHelpers.cs b/back-end/src/RoleHelpers.cs new file mode 100644 index 0000000..a49d72a --- /dev/null +++ b/back-end/src/RoleHelpers.cs @@ -0,0 +1,42 @@ +// Copyright (C) 2024 Vaughn Nugent +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as +// published by the Free Software Foundation, either version 3 of the +// License, or (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +using VNLib.Plugins.Essentials.Accounts; +using VNLib.Plugins.Essentials.Users; +using VNLib.Plugins.Essentials.Sessions; + +namespace SimpleBookmark +{ + internal static class RoleHelpers + { + public const ulong CanAddUserRoleOption = 1 << AccountUtil.OPTIONS_MSK_OFFSET; + + /// + /// A minium user role with read/write/delete access to their own bookmarks. + /// + public const ulong MinUserRole = AccountUtil.MINIMUM_LEVEL | AccountUtil.ALLFILE_MSK; + + public static bool CanAddUser(this IUser user) => (user.Privileges & CanAddUserRoleOption) != 0; + + public static bool CanAddUser(this ref readonly SessionInfo session) => (session.Privilages & CanAddUserRoleOption) != 0; + + /// + /// Adds the add-user role to the given privileges for a user. + /// + /// + /// The modified privilege level + public static ulong WithAddUserRole(ulong privs) => privs | CanAddUserRoleOption; + } +} -- cgit