Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const jwt = require('jsonwebtoken');
- app.post('/login', (req,res) => {
- let username = req.body.username
- let password = req.body.password
- bcrypt.compare(password, hash,(err, result) => {
- if(result){
- let token =
- jwt.sign({username:username},'secretkey')
- res.json({token:token)
- } else{
- res.status(403)
- .send({token:null})
- }
- })
- })
Add Comment
Please, Sign In to add comment