Fix authentication flow on client side

This commit is contained in:
Bruce Hem 2016-08-19 22:01:36 +07:00 committed by GitHub
parent 5a5cd7c45a
commit 674bbb659a

View File

@ -28,12 +28,16 @@ __Client side__:
```javascript
var socket = io.connect('http://localhost:9000');
socket.on('connect', function (socket) {
socket.on('connect', function () {
socket
.emit('authenticate', {token: jwt}) //send the jwt
.on('authenticated', function () {
//do other things
})
.emit('authenticate', {token: jwt}); //send the jwt
.on('unauthorized', function(msg) {
console.log("unauthorized: " + JSON.stringify(msg.data));
throw new Error(msg.data.type);
})
});
```