Answers for "passport.authenticate not working"

0

passport.authenticate not working

router.post('/login', (req, res) => {
    passport.authenticate('local', function (err, user, info) {      
        if (err) {
            return res.status(401).json(err);
        }
        if (user) {
            const token = user.generateJwt();
            return res.status(200).json({
                "token": token
            });
        } else {
            res.status(401).json(info);
        }
    })(req, res, next)
})
Posted by: Guest on April-19-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language