Getting out of sync server response
On a successful signup of a user I am currently seeing a mostly empty page
with the text undefined. Redirecting to /app at the top.
I think it is because of the req.redirect call being within the user.save
callback but I am not sure what the fix is.
I am using mongoose for the ORM.
var User = require('../models/user');
module.exports = function(app) {
app.post('/users', function(req, res, next) {
var user = new User({
email: req.body.email,
password: req.body.password
});
user.save(function(err) {
if (err)
res.send(412, {message: err});
else
req.login(user, function(err) {
if (err !== undefined) return next(err);
res.redirect('/app', {
email: user.email,
id: user._id
});
});
});
});
};
Sunday, August 18, 2013
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment