From 5a45606411849fb8cbb39c3065f4ab5480ae2ef6 Mon Sep 17 00:00:00 2001 From: Flam3rboy <34555296+Flam3rboy@users.noreply.github.com> Date: Sun, 3 Oct 2021 01:55:57 +0200 Subject: :sparkles: add ``right`` option to route() --- api/src/middlewares/Authentication.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'api/src/middlewares') diff --git a/api/src/middlewares/Authentication.ts b/api/src/middlewares/Authentication.ts index a300c786..571097bf 100644 --- a/api/src/middlewares/Authentication.ts +++ b/api/src/middlewares/Authentication.ts @@ -1,6 +1,6 @@ import { NextFunction, Request, Response } from "express"; import { HTTPError } from "lambert-server"; -import { checkToken, Config } from "@fosscord/util"; +import { checkToken, Config, Rights } from "@fosscord/util"; export const NO_AUTHORIZATION_ROUTES = [ "/auth/login", @@ -21,6 +21,7 @@ declare global { user_id: string; user_bot: boolean; token: string; + rights: Rights; } } } @@ -46,6 +47,7 @@ export async function Authentication(req: Request, res: Response, next: NextFunc req.token = decoded; req.user_id = decoded.id; req.user_bot = user.bot; + req.rights = new Rights(user.rights); return next(); } catch (error: any) { return next(new HTTPError(error?.toString(), 400)); -- cgit 1.5.1 From c745c765e0733751d62bd65c896860a83f26ccf3 Mon Sep 17 00:00:00 2001 From: afeuerstein <32029275+afeuerstein@users.noreply.github.com> Date: Sun, 3 Oct 2021 20:06:03 +0200 Subject: fix request failiure with error code 400 --- api/src/middlewares/Authentication.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'api/src/middlewares') diff --git a/api/src/middlewares/Authentication.ts b/api/src/middlewares/Authentication.ts index 571097bf..5a082751 100644 --- a/api/src/middlewares/Authentication.ts +++ b/api/src/middlewares/Authentication.ts @@ -47,7 +47,7 @@ export async function Authentication(req: Request, res: Response, next: NextFunc req.token = decoded; req.user_id = decoded.id; req.user_bot = user.bot; - req.rights = new Rights(user.rights); + req.rights = new Rights(Number(user.rights)); return next(); } catch (error: any) { return next(new HTTPError(error?.toString(), 400)); -- cgit 1.5.1