mirror of
https://github.com/Thream/socketio-jwt.git
synced 2024-07-21 09:38:31 +02:00
Merge pull request #100 from BruceHem/patch-1
Fix authentication flow on client side
This commit is contained in:
commit
90f431741b
@ -28,12 +28,16 @@ __Client side__:
|
|||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
var socket = io.connect('http://localhost:9000');
|
var socket = io.connect('http://localhost:9000');
|
||||||
socket.on('connect', function (socket) {
|
socket.on('connect', function () {
|
||||||
socket
|
socket
|
||||||
|
.emit('authenticate', {token: jwt}) //send the jwt
|
||||||
.on('authenticated', function () {
|
.on('authenticated', function () {
|
||||||
//do other things
|
//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);
|
||||||
|
})
|
||||||
});
|
});
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user