socketio-auth
Advanced tools
Comparing version 0.0.3 to 0.0.4
@@ -29,3 +29,3 @@ 'use strict'; | ||
config.authenticate(data, function(err, success) { | ||
config.authenticate(socket, data, function(err, success) { | ||
if (success) { | ||
@@ -32,0 +32,0 @@ debug('Authenticated socket %s', socket.id); |
{ | ||
"name": "socketio-auth", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "Authentication for socket.io", | ||
@@ -18,3 +18,3 @@ "main": "index.js", | ||
"type": "git", | ||
"url": "https://github.com/invisiblejs/socketio-auth" | ||
"url": "https://github.com/facundoolano/socketio-auth" | ||
}, | ||
@@ -31,5 +31,5 @@ "keywords": [ | ||
"bugs": { | ||
"url": "https://github.com/invisiblejs/socketio-auth/issues" | ||
"url": "https://github.com/facundoolano/socketio-auth/issues" | ||
}, | ||
"homepage": "https://github.com/invisiblejs/socketio-auth", | ||
"homepage": "https://github.com/facundoolano/socketio-auth", | ||
"dependencies": { | ||
@@ -36,0 +36,0 @@ "debug": "^2.1.3", |
@@ -21,3 +21,3 @@ # socketio-auth [![Build Status](https://secure.travis-ci.org/invisiblejs/socketio-auth.png)](http://travis-ci.org/invisiblejs/socketio-auth) | ||
require('socketio-auth')(io, { | ||
authenticate: function (data, callback) { | ||
authenticate: function (socket, data, callback) { | ||
//get credentials sent by the client | ||
@@ -37,3 +37,3 @@ var username = data.username; | ||
The client should send an `authentication` event right after connecting, including whatever credentials are needed by the server to identify the user (i.e. user/password, auth token, etc.). The `authenticate` function receives those same credentials and uses them to authenticate. | ||
The client should send an `authentication` event right after connecting, including whatever credentials are needed by the server to identify the user (i.e. user/password, auth token, etc.). The `authenticate` function receives those same credentials in 'data', and the actual 'socket' in case header information like the origin domain is important, and uses them to authenticate. | ||
@@ -59,3 +59,3 @@ ## Configuration | ||
```javascript | ||
function authenticate(data, callback) { | ||
function authenticate(socket, data, callback) { | ||
var username = data.username; | ||
@@ -98,3 +98,3 @@ var password = data.password; | ||
```javascript | ||
function authenticate(data, callback) { | ||
function authenticate(socket, data, callback) { | ||
db.findUser('User', {username:data.username}, function(err, user) { | ||
@@ -105,2 +105,3 @@ if (err || !user) { | ||
} | ||
//if wrong password err.message will be "Authentication failure" | ||
@@ -107,0 +108,0 @@ return callback(null, user.password == data.password); |
@@ -54,3 +54,3 @@ 'use strict'; | ||
function authenticate(data, cb) { | ||
function authenticate(socket, data, cb) { | ||
if (!data.token) { | ||
@@ -57,0 +57,0 @@ cb(new Error('Missing credentials')); |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
15552
117
0