bnoguchi/mongoose-auth — Issue #69: Cannot call method 'authenticate' of undefined
Author: nnarasimha
Created: 2012-01-07 01:08:09+00:00
State: open

I am unable to authenticate with this exception. Below is my code, can someone please help me

UserSchema.plugin(mongooseAuth, {
everymodule: {
everyauth: {
User: function() {
return User;
}
}
}
,password:{
//loginWith: 'email',
everyauth: {
getLoginPath: '/login',
postLoginPath: '/login',
loginView: 'home/login.jade',
getRegisterPath:'/register',
postRegisterPath: '/register',
registerView: 'home/register.jade',
loginSuccessRedirect: '/mallHome',
registerSuccessRedirect: '/mallHome',
extractExtraRegistrationParams: function (req) {
/*return{
first_name: req.body.first_name,
last_name: req.body.last_name,
password_confirm: req.body.password_confirm
}*/
},
validateRegistration: function (newUserAttrs, errors) {

/*if(newUserAttrs.password != newUserAttrs.password_confirm){
errors.push(new Error("passwords dont match"));
}

return errors;*/
},
registerUser: function (newUserAttrs) {

/*delete newUserAttrs.password_confirm;

var promise = this.Promise();
User.createWithPassword(newUserAttrs, function(err, user) {
if (err){
return promise.fulfill([err]);
}
promise.fulfill(user);
});
return promise;*/

},
authenticate: function (login, password) {
var promise
, errors = [];

if (!login) errors.push('Missing login.');
if (!password) errors.push('Missing password.');
if (errors.length) return errors;

promise = this.Promise();
console.log("user:"+login);
this.User()().authenticate(login, password, function (err, user) {
if (err) {
errors.push(err.message || err);
return promise.fulfill(errors);
}
if (!user) {
errors.push('Failed login.');
return promise.fulfill(errors);
}

if (!user) {
errors.push('Failed login.');
return promise.fulfill(errors);
}
});

}
}

}

});