1
0
mirror of https://github.com/spacebarchat/server.git synced 2024-11-11 05:02:37 +01:00
This commit is contained in:
Flam3rboy 2021-09-25 04:20:35 +02:00
parent 6229398316
commit a83c9fe510

View File

@ -81,10 +81,10 @@ export function route(opts: RouteOptions) {
return async (req: Request, res: Response, next: NextFunction) => { return async (req: Request, res: Response, next: NextFunction) => {
if (opts.permission) { if (opts.permission) {
const required = new Permissions(opts.permission); const required = new Permissions(opts.permission);
const permission = await getPermission(req.user_id, req.params.guild_id, req.params.channel_id); req.permission = await getPermission(req.user_id, req.params.guild_id, req.params.channel_id);
// bitfield comparison: check if user lacks certain permission // bitfield comparison: check if user lacks certain permission
if (!permission.has(required)) { if (!req.permission.has(required)) {
throw DiscordApiErrors.MISSING_PERMISSIONS.withParams(opts.permission as string); throw DiscordApiErrors.MISSING_PERMISSIONS.withParams(opts.permission as string);
} }
} }