module.exports = function(app) {
var User = app.models.account;
//login page
app.get('/', function(req, res) {
res.render('login');
});
//verified
app.get('/verified', function(req, res) {
res.render('verified');
});
//log a user in
app.post('/login', function(req, res) {
User.login({
email: req.body.email,
password: req.body.password
}, 'user', function(err, token) {
if (err) {
res.render('response', {
title: 'Login failed',
content: err,
redirectTo: '/',
redirectToLinkText: 'Try again'
});
return;
}
res.render('home', {
email: req.body.email,
accessToken: token.id
});
});
});
}
i am trying to link my model account which has as a base 'User'. and then call the User.login function etc.
but it says Cannot read property 'email' of undefined
why?
this line is what gives the error it says email: req.body.email,