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

Fixed bug introduced by previous commit

parent ded7c1e7
No related branches found
No related tags found
No related merge requests found
...@@ -31,13 +31,14 @@ export async function tokenVerification(req: Request, _res: Response, next: Next ...@@ -31,13 +31,14 @@ export async function tokenVerification(req: Request, _res: Response, next: Next
if (token) { if (token) {
delete req.body.token; delete req.body.token;
try { try {
let decoded;
if (await usePublicAndPrivate()) { if (await usePublicAndPrivate()) {
const decoded = await asyncify(verify, token, await getPublicKey(), { algorithms: ["ES384"] }); decoded = await asyncify(verify, token, await getPublicKey(), { algorithms: ["ES384"] });
if (isOfType<Token>(decoded, [['id', 'string'], ['type', 'string']]) && decoded.type === authTokenType) {
req.body.token = decoded;
}
} else { } else {
return asyncify(verify, token, getSecret(), { algorithms: ["HS384"] }); decoded = await asyncify(verify, token, getSecret(), { algorithms: ["HS384"] });
}
if (isOfType<Token>(decoded, [['id', 'string'], ['type', 'string']]) && decoded.type === authTokenType) {
req.body.token = decoded;
} }
} catch (err) { /* Token has already been deleted */ } } catch (err) { /* Token has already been deleted */ }
next(); 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