summary refs log tree commit diff
diff options
context:
space:
mode:
authorErkin Alp Güney <erkinalp9035@gmail.com>2022-04-07 23:47:26 +0300
committerGitHub <noreply@github.com>2022-04-07 23:47:26 +0300
commitd1f24b25370203a7604853727dc535eb87c21122 (patch)
treeb42ef3f1cf4a5455a75a1063eb80e239fef383d6
parentadded the maintenance listing endpoint (diff)
downloadserver-d1f24b25370203a7604853727dc535eb87c21122.tar.xz
More rights stuff
-rw-r--r--util/src/util/Rights.ts11
1 files changed, 11 insertions, 0 deletions
diff --git a/util/src/util/Rights.ts b/util/src/util/Rights.ts
index db5384d0..dedbfe30 100644
--- a/util/src/util/Rights.ts
+++ b/util/src/util/Rights.ts
@@ -1,6 +1,7 @@
 import { BitField } from "./BitField";
 import "missing-native-js-functions";
 import { BitFieldResolvable, BitFlag } from "./BitField";
+import { User } from "../entities";
 
 var HTTPError: any;
 
@@ -85,6 +86,16 @@ export class Rights extends BitField {
 		// @ts-ignore
 		throw new HTTPError(`You are missing the following rights ${permission}`, 403);
 	}
+	
+	export async function getRight(
+	user_id: string,
+	/** opts: {
+		in_behalf?: (keyof User)[];
+	} = {} **/)
+	{
+		user = await User.findOneOrFail({ where: { id: user_id } });
+		return new Rights(user.right);
+	} 
 }
 
 const ALL_RIGHTS = Object.values(Rights.FLAGS).reduce((total, val) => total | val, BigInt(0));