Skip to content
Snippets Groups Projects
Commit 09fe514a authored by Bernard Roland (Student Com20)'s avatar Bernard Roland (Student Com20)
Browse files

Authorization now chechs the users existence

parent 7ea345e9
No related branches found
No related tags found
No related merge requests found
......@@ -38,7 +38,14 @@ export async function tokenVerification(req: Request, _res: Response, next: Next
decoded = await asyncify(verify, token, getSecret(), { algorithms: ["HS384"] });
}
if (isOfType<Token>(decoded, [['id', 'string'], ['type', 'string']]) && decoded.type === authTokenType) {
req.body.token = decoded;
const user = await database('users')
.select({ id: 'users.id' })
.where({
'users.id': decoded.id,
});
if (user.length >= 1) {
req.body.token = decoded;
}
}
} catch (err) { /* Token has already been deleted */ }
next();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment