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

Invalid tokens are now allowed for unprotected routes

parent d4fef314
No related branches found
No related tags found
No related merge requests found
......@@ -109,7 +109,7 @@ auth.get("/extend", async function (req, res) {
}
});
export async function tokenVerification(req: Request, res: Response, next: NextFunction) {
export async function tokenVerification(req: Request, _res: Response, next: NextFunction) {
const header = req.headers?.authorization;
let token: string | null = null;
if (header) {
......@@ -124,13 +124,10 @@ export async function tokenVerification(req: Request, res: Response, next: NextF
try {
const decoded = await asyncify(verify, token, await getPublicKey(), { algorithms: ["ES384"] });
req.body.token = decoded;
next();
} catch (err) {
res.status(403).json({
status: 'error',
message: 'authentication failed',
});
delete req.body.token;
}
next();
} else {
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