2
1
mirror of https://github.com/Thream/socketio-jwt.git synced 2024-07-21 09:38:31 +02:00

Merge pull request #118 from Root-Core/store-jwt

Added option to store encoded jwt
This commit is contained in:
Conrad Sopala 2019-02-28 17:24:38 +01:00 committed by GitHub
commit fbae634992
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -63,6 +63,9 @@ function noQsMethod(options) {
return onError({message: 'invalid token datatype'}, 'invalid_token'); return onError({message: 'invalid token datatype'}, 'invalid_token');
} }
// Store encoded JWT
socket[options.encodedPropertyName] = data.token;
var onJwtVerificationReady = function(err, decoded) { var onJwtVerificationReady = function(err, decoded) {
if (err) { if (err) {
@ -107,7 +110,7 @@ function noQsMethod(options) {
} }
function authorize(options, onConnection) { function authorize(options, onConnection) {
options = xtend({ decodedPropertyName: 'decoded_token' }, options); options = xtend({ decodedPropertyName: 'decoded_token', encodedPropertyName: 'encoded_token' }, options);
if (!options.handshake) { if (!options.handshake) {
return noQsMethod(options); return noQsMethod(options);
@ -169,6 +172,9 @@ function authorize(options, onConnection) {
return auth.fail(error, data, accept); return auth.fail(error, data, accept);
} }
// Store encoded JWT
data[options.encodedPropertyName] = token;
var onJwtVerificationReady = function(err, decoded) { var onJwtVerificationReady = function(err, decoded) {
if (err) { if (err) {