-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
| const token = sign(decoded, MASTER_PRIVATE_KEY.replace(/\\n/g, '\n'), { |
This code is broken. sign returns a promise but it's being assigned to token. Needs to be refactored like this :
const maybeOfferNewTokenHeader = () => Promise.resolve()
.then(() => MASTER_PRIVATE_KEY ? sign(
decoded,
MASTER_PRIVATE_KEY.replace(/\\n/g, '\n'), {
algorithm : 'RS256',
expiresIn : process.env.JWT_TTL || '20s'
}) : req.get('x-auth-token')
)
.then(token => {
res.set('x-auth-token', token);
});
return Promise.resolve(secret)
.then(verifyRSJWT(verify)(token))
.then(maybeOfferNewTokenHeader)
.then(setReqUser)
.then(() => continueWithErrorIfNotPermitted(axios, checkPermission)(decoded, req, next));
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels