mirror of
https://github.com/Thream/socketio-jwt.git
synced 2024-07-21 09:38:31 +02:00
Fix authentication for namespaces #95
Try to get the token from query string, which is stored in the sockets "handshake" object. This should fix #95 and be a more elegant (say valid) approach.
This commit is contained in:
parent
90f431741b
commit
640e8d0ef0
@ -133,6 +133,7 @@ function authorize(options, onConnection) {
|
|||||||
return function(data, accept){
|
return function(data, accept){
|
||||||
var token, error;
|
var token, error;
|
||||||
var req = data.request || data;
|
var req = data.request || data;
|
||||||
|
var handshake = data.handshake;
|
||||||
var authorization_header = (req.headers || {}).authorization;
|
var authorization_header = (req.headers || {}).authorization;
|
||||||
|
|
||||||
if (authorization_header) {
|
if (authorization_header) {
|
||||||
@ -152,8 +153,11 @@ function authorize(options, onConnection) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//get the token from query string
|
//get the token from handshake or query string
|
||||||
if (req._query && req._query.token) {
|
if (handshake && handshake.query.token){
|
||||||
|
token = handshake.query.token;
|
||||||
|
}
|
||||||
|
else if (req._query && req._query.token) {
|
||||||
token = req._query.token;
|
token = req._query.token;
|
||||||
}
|
}
|
||||||
else if (req.query && req.query.token) {
|
else if (req.query && req.query.token) {
|
||||||
|
Loading…
Reference in New Issue
Block a user