From bcf6c0b719360b7815ea73ac8622eeec0427f13c Mon Sep 17 00:00:00 2001 From: Kerollos Magdy Date: Tue, 29 Oct 2019 12:39:38 +0200 Subject: [PATCH] add example for using customDecoded function --- README.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/README.md b/README.md index 8354917..b5c9d15 100644 --- a/README.md +++ b/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 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).