aboutsummaryrefslogtreecommitdiff
path: root/src/lib/Utility/authorisation.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/Utility/authorisation.ts')
-rw-r--r--src/lib/Utility/authorisation.ts9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/lib/Utility/authorisation.ts b/src/lib/Utility/authorisation.ts
new file mode 100644
index 00000000..c6b64414
--- /dev/null
+++ b/src/lib/Utility/authorisation.ts
@@ -0,0 +1,9 @@
+/**
+ * Whether a caller may act on resources belonging to `targetUserId`: either the
+ * caller owns them, or the caller is a privileged (allow-listed) user.
+ */
+export const isOwnerOrPrivileged = (
+ callerUserId: number,
+ targetUserId: number,
+ privileged: boolean,
+) => privileged || callerUserId === targetUserId;