From d340c81fd5c44502c4146ea172f8411d65682db2 Mon Sep 17 00:00:00 2001 From: Root-Core Date: Tue, 18 Apr 2017 23:31:38 +0200 Subject: [PATCH 1/3] Added option to store encoded jwt, default "encoded_token" --- lib/index.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/index.js b/lib/index.js index bfcb715..54b33b7 100644 --- a/lib/index.js +++ b/lib/index.js @@ -61,6 +61,9 @@ function noQsMethod(options) { return onError({message: 'invalid token datatype'}, 'invalid_token'); } + // Store encoded JWT + socket[options.encodedPropertyName] = token; + var onJwtVerificationReady = function(err, decoded) { if (err) { @@ -105,7 +108,7 @@ function noQsMethod(options) { } function authorize(options, onConnection) { - options = xtend({ decodedPropertyName: 'decoded_token' }, options); + options = xtend({ decodedPropertyName: 'decoded_token', encodedPropertyName: 'encoded_token' }, options); if (!options.handshake) { return noQsMethod(options); @@ -167,6 +170,9 @@ function authorize(options, onConnection) { return auth.fail(error, data, accept); } + // Store encoded JWT + socket[options.encodedPropertyName] = token; + var onJwtVerificationReady = function(err, decoded) { if (err) { From 025952dcc7fbe552d20f0b40f709ba38e1464736 Mon Sep 17 00:00:00 2001 From: Root-Core Date: Tue, 18 Apr 2017 23:56:22 +0200 Subject: [PATCH 2/3] Fixed dirty cherry-pick --- lib/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/index.js b/lib/index.js index 54b33b7..1971132 100644 --- a/lib/index.js +++ b/lib/index.js @@ -171,7 +171,7 @@ function authorize(options, onConnection) { } // Store encoded JWT - socket[options.encodedPropertyName] = token; + data[options.encodedPropertyName] = token; var onJwtVerificationReady = function(err, decoded) { From cc3d6b22b730b6214ef9fefc6b59e85a111aa738 Mon Sep 17 00:00:00 2001 From: Root-Core Date: Wed, 19 Apr 2017 00:01:18 +0200 Subject: [PATCH 3/3] Fixed dirty copy and paste mistake.. --- lib/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/index.js b/lib/index.js index 1971132..6d96683 100644 --- a/lib/index.js +++ b/lib/index.js @@ -62,7 +62,7 @@ function noQsMethod(options) { } // Store encoded JWT - socket[options.encodedPropertyName] = token; + socket[options.encodedPropertyName] = data.token; var onJwtVerificationReady = function(err, decoded) {