I am integrating SailsJS and Passport. I have a fairly simply controller but during the "process" method where I process the login I get the following error:
TypeError: Object #<Object>
has no method 'authenticate'
You can see in the controller I am calling the passport.authenticate() method, according to docs this should exist.
LoginController.js
module.exports = {
login: function(req, res) {
res.view("login",{});
},
process: function(req, res) {
passport.authenticate('local', function(err, user, info) {
if( (err)||(!user) ) {
return res.send({
message: 'login failed'
});
res.send(err);
}
req.logIn(user, function(err) {
if(err) res.send(err);
return res.send({
message: 'login successful'
});
});
}) (req, res);
},
logout: function(req, res) {
req.logOut();
res.send('logout successful');
}
};