Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wiki-js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
wiki-js
Commits
0e6340f5
Unverified
Commit
0e6340f5
authored
Jun 18, 2020
by
Regev Brody
Committed by
GitHub
Jun 18, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: use config value for tokenRenewal expiration (#2042)
* fix: tokenRenewal seems to be hard coded #1540
parent
330c9022
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
1 deletion
+3
-1
auth.js
server/core/auth.js
+3
-1
No files found.
server/core/auth.js
View file @
0e6340f5
...
...
@@ -2,6 +2,7 @@ const passport = require('passport')
const
passportJWT
=
require
(
'passport-jwt'
)
const
_
=
require
(
'lodash'
)
const
jwt
=
require
(
'jsonwebtoken'
)
const
ms
=
require
(
'ms'
)
const
moment
=
require
(
'moment'
)
const
Promise
=
require
(
'bluebird'
)
const
crypto
=
Promise
.
promisifyAll
(
require
(
'crypto'
))
...
...
@@ -112,7 +113,8 @@ module.exports = {
if
(
err
)
{
return
next
()
}
// Expired but still valid within N days, just renew
if
(
info
instanceof
Error
&&
info
.
name
===
'TokenExpiredError'
&&
moment
().
subtract
(
14
,
'days'
).
isBefore
(
info
.
expiredAt
))
{
if
(
info
instanceof
Error
&&
info
.
name
===
'TokenExpiredError'
&&
moment
().
subtract
(
ms
(
WIKI
.
config
.
auth
.
tokenRenewal
),
'ms'
).
isBefore
(
info
.
expiredAt
))
{
const
jwtPayload
=
jwt
.
decode
(
securityHelper
.
extractJWT
(
req
))
try
{
const
newToken
=
await
WIKI
.
models
.
users
.
refreshToken
(
jwtPayload
.
id
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment