Browse Source

fix: TokenExpiredError no longer recognized

pull/760/head
Nicolas Giard 6 years ago
parent
commit
157110ed90
1 changed files with 1 additions and 1 deletions
  1. 2
      server/middlewares/auth.js

2
server/middlewares/auth.js

@ -14,7 +14,7 @@ module.exports = {
if (err) { return next() }
// Expired but still valid within 7 days, just renew
if (info instanceof jwt.TokenExpiredError && moment().subtract(14, 'days').isBefore(info.expiredAt)) {
if (info instanceof Error && info.name === 'TokenExpiredError' && moment().subtract(14, 'days').isBefore(info.expiredAt)) {
const jwtPayload = jwt.decode(securityHelper.extractJWT(req))
try {
const newToken = await WIKI.models.users.refreshToken(jwtPayload.id)

Loading…
Cancel
Save