Check token expiry in bearer auth
This commit is contained in:
parent
1b8e94ca40
commit
2dc7fa5df8
1 changed files with 5 additions and 0 deletions
|
|
@ -55,6 +55,11 @@ export function requireBearerAuth({ provider, requiredScopes = [] }: BearerAuthM
|
|||
}
|
||||
}
|
||||
|
||||
// Check if the token is expired
|
||||
if (!!authInfo.expiresAt && authInfo.expiresAt < Date.now() / 1000) {
|
||||
throw new InvalidTokenError("Token has expired");
|
||||
}
|
||||
|
||||
req.auth = authInfo;
|
||||
next();
|
||||
} catch (error) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue