mirror of
https://github.com/Thream/socketio-jwt.git
synced 2024-07-21 09:38:31 +02:00
Pass token header to secret fetching function
Depending of function arity pass decoded header of the token. This is to allow backward compatibilty.
This commit is contained in:
parent
5720a50798
commit
e7c826735c
@ -243,13 +243,18 @@ function getSecret (request, secret, token, callback) {
|
||||
return callback({ code: 'invalid_token', message: 'jwt signature is required' });
|
||||
}
|
||||
|
||||
let decodedToken = jwt.decode(token);
|
||||
let decodedToken = jwt.decode(token, { complete: true });
|
||||
|
||||
if (!decodedToken) {
|
||||
return callback({ code: 'invalid_token', message: 'jwt malformed' });
|
||||
}
|
||||
|
||||
secret(request, decodedToken, callback);
|
||||
const arity = secret.length;
|
||||
if (arity == 4) {
|
||||
secret(request, decodedToken.header, decodedToken.payload, callback);
|
||||
} else { // arity == 3
|
||||
secret(request, decodedToken.payload, callback);
|
||||
}
|
||||
} else {
|
||||
callback(null, secret);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user