I'm trying to use Passport with Compound Js. I've configured the passport in an initialization file. as below
var passport = require('passport')
, LocalStrategy = require('passport-local').Strategy;
passport.use(new LocalStrategy({usernameField: 'email'},
function(email, password, done) {
User.findOne({ email: email }, function(err, user) {
if (err) { return done(err); }
if (!user) {
return done(null, false, { message: 'Incorrect username.' });
}
if (!user.validPassword(password)) {
return done(null, false, { message: 'Incorrect password.' });
}
return done(null, user);
});
}
));
module.exports.passport = passport;
And in my routes file I have:
var passobj = require('./initializers/initialize_passport')
exports.routes = function (map) {
map.post("api/users", passobj.passport.authenticate('local', {successRedirect: 'user#index', failureRedirect: 'user#failureoccured'}));
};
When I tried to call this from firebug by passing a valid username and password, I get the below error:
Undefined action undefined#undefined
Can anyone please tell me how to use Passport with Compound Js.
And also I came accross compound-passport, but don't know if I can use it for local strategy. Thanks in advance.