Browse Source

fix: token renewal date

pull/2163/head
NGPixel 4 years ago
parent
commit
31661b2cb3
2 changed files with 8 additions and 2 deletions
  1. 3
      dev/cypress/ci-setup.sh
  2. 7
      server/core/auth.js

3
dev/cypress/ci-setup.sh

@ -20,6 +20,9 @@ mssql)
sleep 30 sleep 30
docker exec db /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "Password123!" -Q 'CREATE DATABASE wiki' 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 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) sqlite)
echo "Using SQLite..." echo "Using SQLite..."

7
server/core/auth.js

@ -114,8 +114,11 @@ module.exports = {
let mustRevalidate = false let mustRevalidate = false
// Expired but still valid within N days, just renew // 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 // Check if user / group is in revocation list

Loading…
Cancel
Save