mirror of
https://github.com/Thream/socketio-jwt.git
synced 2024-07-21 09:38:31 +02:00
add example for using customDecoded function
This commit is contained in:
parent
6af672cca2
commit
bcf6c0b719
23
README.md
23
README.md
@ -251,6 +251,29 @@ io.use(socketioJwt.authorize({
|
|||||||
}));
|
}));
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Altering the value of the decoded token
|
||||||
|
|
||||||
|
You can pass a function to change the value of the decoded token
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
|
||||||
|
io.on(
|
||||||
|
'connection',
|
||||||
|
socketIOJwt.authorize({
|
||||||
|
customDecoded: (decoded) => {
|
||||||
|
return "new decoded token";
|
||||||
|
},
|
||||||
|
secret: 'my_secret_key',
|
||||||
|
decodedPropertyName: 'my_decoded_token',
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
io.on('authenticated', (socket) => {
|
||||||
|
console.log(socket.my_decoded_token); // new decoded token
|
||||||
|
});
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
## Contribute
|
## Contribute
|
||||||
|
|
||||||
Feel like contributing to this repo? We're glad to hear that! Before you start contributing please visit our [Contributing Guideline](https://github.com/auth0-community/getting-started/blob/master/CONTRIBUTION.md).
|
Feel like contributing to this repo? We're glad to hear that! Before you start contributing please visit our [Contributing Guideline](https://github.com/auth0-community/getting-started/blob/master/CONTRIBUTION.md).
|
||||||
|
Loading…
Reference in New Issue
Block a user