diff --git a/src/middlewares/verify-token.ts b/src/middlewares/verify-token.ts index 7273ff9501c563e9516e7c7073a92fde4e78e0c1..82d225740e9cefc8394990976557dc938bae585d 100644 --- a/src/middlewares/verify-token.ts +++ b/src/middlewares/verify-token.ts @@ -58,12 +58,12 @@ const verifyToken = async (req: Request, res: Response, next: NextFunction) => { next(); // The token is verified, pass to the next middleware } catch (error) { if (error instanceof TokenExpiredError) { - throw new StandardError(ErrorType.ACCESS_TOKEN_EXPIRED); + next(new StandardError(ErrorType.ACCESS_TOKEN_EXPIRED)); } else if (error instanceof NotBeforeError) { - throw new StandardError(ErrorType.ACCESS_TOKEN_NOT_ACTIVE); + next(new StandardError(ErrorType.ACCESS_TOKEN_NOT_ACTIVE)); } - - throw error; + // unknown error + next(error); } };