You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
varjwt=require('jsonwebtoken');...router.post('/login',function(req,res){moduleUser.User.findOne({username: req.body.username},function(err,user){if(err)res.status(401).json({success: false,message: "Error"});if(user){user.comparePassword(req.body.password,function(err,isMatch){if(isMatch&&!err){// Create token if the password matched and no error was thrownvartoken=jwt.sign(user,'my_secret',{expiresIn: 10000});// in secondsres.json({success: true,token: 'JWT '+token});}else{res.status(401).json({success: false,message: err});}})}else{res.status(401).json({success: false,message: "Invalid credentials"});}});});
Sorry if this is a stupid question, but how can I get a token for authentication? 😄
The text was updated successfully, but these errors were encountered: