summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-05-21 17:48:20 +0200
committerFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-05-21 17:48:20 +0200
commitf456a9b1f3175c298644be276be01f79027e9d5d (patch)
tree1b372faf63291744597baaabb7363ead5857ba28 /src
parent:sparkles: [Message] Model add created_at (diff)
downloadserver-f456a9b1f3175c298644be276be01f79027e9d5d.tar.xz
:bug: convert string to bigint Permissions
Diffstat (limited to 'src')
-rw-r--r--src/util/Database.ts10
-rw-r--r--src/util/Permissions.ts4
2 files changed, 11 insertions, 3 deletions
diff --git a/src/util/Database.ts b/src/util/Database.ts
index 863df663..e5323ed6 100644
--- a/src/util/Database.ts
+++ b/src/util/Database.ts
@@ -19,7 +19,15 @@ export default <Connection>connection;
 
 function transform<T>(document: T) {
 	// @ts-ignore
-	if (!document || !document.toObject) return document;
+	if (!document || !document.toObject) {
+		try {
+			// @ts-ignore
+			delete document._id;
+			// @ts-ignore
+			delete document.__v;
+		} catch (error) {}
+		return document;
+	}
 	// @ts-ignore
 	return document.toObject({ virtuals: true });
 }
diff --git a/src/util/Permissions.ts b/src/util/Permissions.ts
index 588d7bb9..4627143a 100644
--- a/src/util/Permissions.ts
+++ b/src/util/Permissions.ts
@@ -124,7 +124,7 @@ export class Permissions extends BitField {
 			// * permission: current calculated permission (e.g. 010)
 			// * deny contains all denied permissions (e.g. 011)
 			// * allow contains all explicitly allowed permisions (e.g. 100)
-			return (permission & ~overwrite.deny) | overwrite.allow;
+			return (permission & ~BigInt(overwrite.deny)) | BigInt(overwrite.allow);
 			// ~ operator inverts deny (e.g. 011 -> 100)
 			// & operator only allows 1 for both ~deny and permission (e.g. 010 & 100 -> 000)
 			// | operators adds both together (e.g. 000 + 100 -> 100)
@@ -133,7 +133,7 @@ export class Permissions extends BitField {
 
 	static rolePermission(roles: Role[]) {
 		// adds all permissions of all roles together (Bit OR)
-		return roles.reduce((permission, role) => permission | role.permissions, 0n);
+		return roles.reduce((permission, role) => permission | BigInt(role.permissions), 0n);
 	}
 
 	static finalPermission({