Video 106: JSON Web Tokens
This commit is contained in:
@@ -14,17 +14,14 @@ app.listen(port, () => {
|
||||
console.log('Server is up on port ' + port)
|
||||
})
|
||||
|
||||
const bcrypt = require('bcryptjs')
|
||||
const jwt = require('jsonwebtoken')
|
||||
|
||||
const myFunction = async () => {
|
||||
const password = 'Red12345!'
|
||||
const hashedPassword = await bcrypt.hash(password, 8)
|
||||
const token = jwt.sign({ _id: 'abc123' }, 'thisismynewcourse', { expiresIn: '7 days' })
|
||||
console.log(token)
|
||||
|
||||
console.log(password)
|
||||
console.log(hashedPassword)
|
||||
|
||||
const isMatch = await bcrypt.compare('red12345!', hashedPassword)
|
||||
console.log(isMatch)
|
||||
const data = jwt.verify(token, 'thisismynewcourse')
|
||||
console.log(data)
|
||||
}
|
||||
|
||||
myFunction()
|
||||
|
||||
Reference in New Issue
Block a user