From 31661b2cb3b325ad8e43fd34766a3eda841f546f Mon Sep 17 00:00:00 2001 From: NGPixel Date: Sun, 5 Jul 2020 14:16:16 -0400 Subject: [PATCH] fix: token renewal date --- dev/cypress/ci-setup.sh | 3 +++ server/core/auth.js | 7 +++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/dev/cypress/ci-setup.sh b/dev/cypress/ci-setup.sh index d504226d..7d03a014 100644 --- a/dev/cypress/ci-setup.sh +++ b/dev/cypress/ci-setup.sh @@ -20,6 +20,9 @@ mssql) sleep 30 docker exec db /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "Password123!" -Q 'CREATE DATABASE wiki' docker run -d -p 3000:3000 --name wiki --network="host" -e "DB_TYPE=mssql" -e "DB_HOST=localhost" -e "DB_PORT=1433" -e "DB_NAME=wiki" -e "DB_USER=SA" -e "DB_PASS=Password123!" requarks/wiki:canary-$BUILD_BUILDNUMBER + docker logs wiki + sleep 15 + docker logs wiki ;; sqlite) echo "Using SQLite..." diff --git a/server/core/auth.js b/server/core/auth.js index d658d7a6..ae5df07b 100644 --- a/server/core/auth.js +++ b/server/core/auth.js @@ -114,8 +114,11 @@ module.exports = { let mustRevalidate = false // Expired but still valid within N days, just renew - if (info instanceof Error && info.name === 'TokenExpiredError' && DateTime.utc().minus(ms(WIKI.config.auth.tokenRenewal)) < DateTime.fromISO(info.expiredAt)) { - mustRevalidate = true + if (info instanceof Error && info.name === 'TokenExpiredError') { + const expiredDate = (info.expiredAt instanceof Date) ? info.expiredAt.toISOString() : info.expiredAt + if (DateTime.utc().minus(ms(WIKI.config.auth.tokenRenewal)) < DateTime.fromISO(expiredDate)) { + mustRevalidate = true + } } // Check if user / group is in revocation list