From 391a4b5e4bbe6530d9cc58452f5eb8b0a81997e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20M=C3=BCller?= Date: Tue, 15 Jun 2021 10:37:14 +0200 Subject: [PATCH] BETTERZON-145: Adding better error when trying to get session details without cookie --- Backend/src/models/users/users.router.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Backend/src/models/users/users.router.ts b/Backend/src/models/users/users.router.ts index 79c3034..d1ca782 100644 --- a/Backend/src/models/users/users.router.ts +++ b/Backend/src/models/users/users.router.ts @@ -95,6 +95,12 @@ usersRouter.post('/checkSessionValid', async (req: Request, res: Response) => { try { const ip: string = req.connection.remoteAddress ?? ''; + if(!req.cookies.betterauth) { + // Error logging in, probably wrong username / password + res.status(401).send(JSON.stringify({messages: ['No session detected'], codes: [5]})); + return; + } + // Update the user entry and create a session const user: User = await UserService.checkSessionWithCookie(req.cookies.betterauth, ip);