Merge pull request #83 from Mueller-Patrick/BETTERZON-145

BETTERZON-145: Adding better error when trying to get session details…
This commit is contained in:
Patrick 2021-06-15 10:38:52 +02:00 committed by GitHub
commit f1dcaef351
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -95,6 +95,12 @@ usersRouter.post('/checkSessionValid', async (req: Request, res: Response) => {
try { try {
const ip: string = req.connection.remoteAddress ?? ''; 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 // Update the user entry and create a session
const user: User = await UserService.checkSessionWithCookie(req.cookies.betterauth, ip); const user: User = await UserService.checkSessionWithCookie(req.cookies.betterauth, ip);