Simple Username-Password Authentication

suggest change

In your routes/index.js


Here user is the model for the userSchema

router.post('/login', function(req, res, next) {
    if (!req.body.username || !req.body.password) {
        return res.status(400).json({
            message: 'Please fill out all fields'
        });
    }
    
    passport.authenticate('local', function(err, user, info) {
        if (err) {
            console.log("ERROR : " + err);
            return next(err);
        }

        if(user) (
            console.log("User Exists!")
            //All the data of the user can be accessed by user.x
            res.json({"success" : true});
            return;
        } else {
            res.json({"success" : false});
            console.log("Error" + errorResponse());
            return;
        }
    })(req, res, next);
});

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:


Passport integration:
* Simple Username-Password Authentication

Table Of Contents
1 npm
41 cli
43 grunt
59 Hack
64 ES6
67 Redis
69 MongoDB
70 Passport integration
86 MongoDB
87 Lodash
91 CORS
105 N-API
108 Require