Skip to content

Instantly share code, notes, and snippets.

@travist
Created June 12, 2020 03:23
Show Gist options
  • Save travist/39dc70cce53903aabb54fa5f40f594d6 to your computer and use it in GitHub Desktop.
Save travist/39dc70cce53903aabb54fa5f40f594d6 to your computer and use it in GitHub Desktop.
const jwt = require('jsonwebtoken');
var token = jwt.sign({
external: true,
form: {
_id: '59795d259be16e3ee58fddaa',
},
project: {
_id: '59795d259be16e3ee58fdda6'
},
user: {
_id: 'external',
data: {
name: 'joe'
},
roles: [
'59795d259be16e3ee58fdda7'
]
}
}, 'JWT_SECRET');
console.log(token);
jwt.verify(token, 'JWT_SECRET', (err, decoded) => {
if (err) {
console.log(err);
return;
}
console.log('login success!');
console.log(decoded);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment