Skip to content
This repository has been archived by the owner on Oct 3, 2023. It is now read-only.

Commit

Permalink
feat(auth): add automatic expired token deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
GGORG0 committed Aug 3, 2022
1 parent f1e7cc0 commit 5493224
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/routes/authRouter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,12 @@ export function authenticateJWT(req: Request, res: Response, next: NextFunction)
next();
}
catch (err) {
if (typeof err === typeof TokenExpiredError) {
if (err instanceof TokenExpiredError) {
await prisma.authJWT.delete({
where: {
token: token,
},
}).catch();
throw new ExpiredTokenError;
}
else {
Expand Down

0 comments on commit 5493224

Please sign in to comment.