From f456a9b1f3175c298644be276be01f79027e9d5d Mon Sep 17 00:00:00 2001 From: Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> Date: Fri, 21 May 2021 17:48:20 +0200 Subject: [PATCH] :bug: convert string to bigint Permissions --- src/util/Database.ts | 10 +++++++++- src/util/Permissions.ts | 4 ++-- 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; function transform(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({