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-02-17 18:12:07 +0100
committerFlam3rboy <34555296+Flam3rboy@users.noreply.github.com>2021-02-17 18:12:07 +0100
commiteca7b96de39e5e4b0feead4c874dd60d395fd91c (patch)
treec79f6d16c85d2e2d17b286a94b7ae385327a2e64 /src/middlewares/Authentication.ts
parent:bug: fix db (diff)
downloadserver-eca7b96de39e5e4b0feead4c874dd60d395fd91c.tar.xz
:bug: fix token checking
Diffstat (limited to 'src/middlewares/Authentication.ts')
-rw-r--r--src/middlewares/Authentication.ts11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/middlewares/Authentication.ts b/src/middlewares/Authentication.ts

index d6eb5796..2bb8a124 100644 --- a/src/middlewares/Authentication.ts +++ b/src/middlewares/Authentication.ts
@@ -18,8 +18,13 @@ export async function Authentication(req: Request, res: Response, next: NextFunc if (!req.headers.authorization) return next(new HTTPError("Missing Authorization Header", 401)); // TODO: check if user is banned/token expired - const decoded: any = await checkToken(req.headers.authorization); + try { + const decoded: any = await checkToken(req.headers.authorization); - req.token = decoded; - req.userid = decoded.id; + req.token = decoded; + req.userid = decoded.id; + return next(); + } catch (error) { + return next(error); + } }