From 5c8c108818fef5416def5c1e37071a9ae3d707c8 Mon Sep 17 00:00:00 2001 From: Jakob Meier Date: Thu, 23 Mar 2023 10:19:36 +0100 Subject: [PATCH] Added server-wide permissions according to https://codeberg.org/outbag/server/src/branch/dev/src/server/permissions.ts --- lib/backend/permissions.dart | 39 ++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/lib/backend/permissions.dart b/lib/backend/permissions.dart index def3370..6c8cf9f 100644 --- a/lib/backend/permissions.dart +++ b/lib/backend/permissions.dart @@ -5,10 +5,45 @@ // same as javascript 0b prefix // pronounced o-b int oB(String binary) { - return int.parse(binary, radix: 2); + return int.parse(binary, radix: 2); } -class ServerPermission {} +class ServerPermission { + static int get none { + return oB("0000000000000000"); + } + // default permission set + static int get def { + return oB("0000000000000011"); + } + static int get canUseAPI { + return oB("0000000000000001"); + } + static int get provideCert { + return oB("0000000000000010"); + } + static int get manageOTA { + return oB("0000010000000000"); + } + static int get manageServerProductList { + return oB("0000100000000000"); + } + static int get viewUsersAndLists { + return oB("0001000000000000"); + } + static int get editSettings { + return oB("0010000000000000"); + } + static int get editPermissions { + return oB("0100000000000000"); + } + static int get editUsers { + return oB("1000000000000000"); + } + static int get all { + return oB("1111111111111111"); + } +} class RoomPermission { static int get addArticles {