summary refs log tree commit diff
path: root/api/src/middlewares/Authentication.ts
diff options
context:
space:
mode:
authorFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-10-03 01:55:57 +0200
committerFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-10-03 01:55:57 +0200
commit5a45606411849fb8cbb39c3065f4ab5480ae2ef6 (patch)
tree97d9ba2a2f725f90656f0910631a82cbbb27ba6a /api/src/middlewares/Authentication.ts
parent:sparkles: User instance rights (diff)
downloadserver-5a45606411849fb8cbb39c3065f4ab5480ae2ef6.tar.xz
:sparkles: add ``right`` option to route()
Diffstat (limited to 'api/src/middlewares/Authentication.ts')
-rw-r--r--api/src/middlewares/Authentication.ts4
1 files changed, 3 insertions, 1 deletions
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));