summary refs log tree commit diff
path: root/src/middlewares/Authentication.ts
diff options
context:
space:
mode:
authorFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-05-27 18:15:33 +0200
committerFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-05-27 18:15:33 +0200
commitb00815b025575bfe79f6f5d2d4004b8da9b9b946 (patch)
tree1d86d7767ba8f29396421ca0ed37afb892214252 /src/middlewares/Authentication.ts
parent:bug: fix bans (diff)
parent:arrow_up: npm i @fosscord/server-util@1.3.5 (diff)
downloadserver-b00815b025575bfe79f6f5d2d4004b8da9b9b946.tar.xz
Merge branch 'master' of https://github.com/fosscord/fosscord-api
Diffstat (limited to 'src/middlewares/Authentication.ts')
-rw-r--r--src/middlewares/Authentication.ts9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/middlewares/Authentication.ts b/src/middlewares/Authentication.ts

index 0ecc1bc0..630a45ff 100644 --- a/src/middlewares/Authentication.ts +++ b/src/middlewares/Authentication.ts
@@ -1,13 +1,13 @@ import { NextFunction, Request, Response } from "express"; import { HTTPError } from "lambert-server"; -import { checkToken } from "@fosscord/server-util"; +import { checkToken, Config } from "@fosscord/server-util"; export const NO_AUTHORIZATION_ROUTES = [ "/api/v8/auth/login", "/api/v8/auth/register", "/api/v8/webhooks/", "/api/v8/gateway", - "/api/v8/experiments", + "/api/v8/experiments" ]; declare global { @@ -24,10 +24,11 @@ export async function Authentication(req: Request, res: Response, next: NextFunc if (req.url.startsWith("/api/v8/invites") && req.method === "GET") return next(); if (NO_AUTHORIZATION_ROUTES.some((x) => req.url.startsWith(x))) return next(); if (!req.headers.authorization) return next(new HTTPError("Missing Authorization Header", 401)); - // TODO: check if user is banned/token expired try { - const decoded: any = await checkToken(req.headers.authorization); + const { jwtSecret } = Config.get().security; + + const decoded: any = await checkToken(req.headers.authorization, jwtSecret); req.token = decoded; req.user_id = decoded.id;