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
commit7268779dc3e9a428d3a95012ca4ba5e1e3d0ca7a (patch)
tree9e6f0ce883e13f6320f45abd68955498f8dc2c7c /api/src/middlewares/Authentication.ts
parent:sparkles: User instance rights (diff)
downloadserver-7268779dc3e9a428d3a95012ca4ba5e1e3d0ca7a.tar.xz
:sparkles: add ``right`` option to route()
Diffstat (limited to '')
-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));