passport authenticate not working

Solutions on MaxInterview for passport authenticate not working by the best coders in the world

showing results for - "passport authenticate not working"
Lennard
11 Sep 2018
1router.post('/login', (req, res) => {
2    passport.authenticate('local', function (err, user, info) {      
3        if (err) {
4            return res.status(401).json(err);
5        }
6        if (user) {
7            const token = user.generateJwt();
8            return res.status(200).json({
9                "token": token
10            });
11        } else {
12            res.status(401).json(info);
13        }
14    })(req, res, next)
15})