:bug: convert string to bigint Permissions
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({
|