Created
June 12, 2020 03:23
-
-
Save travist/39dc70cce53903aabb54fa5f40f594d6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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