Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Time frame corrected to refresh token soon to expire. #54

Merged
merged 2 commits into from
May 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -141,4 +141,5 @@ build
*.LICENSE
CD.sh
PUB.sh
CREATE.sh
CREATE.sh
tsconfig.tsbuildinfo
4 changes: 2 additions & 2 deletions src/lambda-edge/check-auth/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ export const handler: CloudFrontRequestHandler = async (event) => {
if (!tokenUserName || !idToken) {
throw new Error('No valid credentials present in cookies');
}
// If the token has (nearly) expired and there is a refreshToken: refresh tokens
// If the token has expired or expires in less than 5 minutes and there is a refreshToken: refresh tokens
const { exp } = decodeToken(idToken);
if ((Date.now() / 1000) - (60 * 5) > exp && refreshToken) {
if ((Date.now() / 1000) > exp - (60 * 5) && refreshToken) {
return {
status: '307',
statusDescription: 'Temporary Redirect',
Expand Down
Loading