From 729d5530beea8c039a7514b337de3c96f7b7f1f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krist=C3=B3f=20Poduszl=C3=B3?= Date: Wed, 15 Jun 2016 08:25:40 +0200 Subject: [PATCH] Added ability to use a custom decodedPropertyName --- lib/index.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/index.js b/lib/index.js index 41d951b..314b688 100644 --- a/lib/index.js +++ b/lib/index.js @@ -53,7 +53,7 @@ function noQsMethod(options) { // success handler var onSuccess = function() { - socket.decoded_token = decoded; + socket[options.decodedPropertyName] = decoded; socket.emit('authenticated'); if (server.$emit) { server.$emit('authenticated', socket); @@ -89,6 +89,8 @@ function noQsMethod(options) { } function authorize(options, onConnection) { + options = xtend({ decodedPropertyName: 'decoded_token' }, options); + if (!options.handshake) { return noQsMethod(options); } @@ -156,7 +158,7 @@ function authorize(options, onConnection) { return auth.fail(error, data, accept); } - data.decoded_token = decoded; + data[options.decodedPropertyName] = decoded; return auth.success(data, accept); };