NodeJS and Passport registration not working - no errors
I have posted the current version on github: https://github.com/rcbgit/boiler
The user appears to be "logged in." At least a successful redirect happens with a valid username / pw, and a failure redirect happens with a bad combo. The problem I am facing is that I do not know how to store information about a user after login or check the page against him (restrict access). I created a basic "Auth" service that stores user information, but I'm not sure how to use it correctly.
I also find it difficult to figure out how to handle messages from the server such as "Username already exists!".
Any advice is appreciated!
source to share
A few things:
1) I am guessing the flash messages are not showing that well. I also had problems with this, so I went back to using the session itself for messaging. Here's what I did, but it just worked:
I changed req.flash to this:
req.session.signUpMessages.push('That email is already taken.');
and then changed in my template to display this variable, if it exists, works like a spell.
2) I think you can and should remove process.nextTick, this is great when you are authenticating against external APIs, which can take a long time, in this case it is more likely due to too much IMO. I would remove it.
3), and last but not least, I think you are missing the parentheses.
if (err)
console.log(err);
return done(err);
^^^^^^^^^^^^^^^^
this get called each time, that not what you want...:)
should pay attention to this:
if (err) {
console.log(err);
return done(err);
}
Try these changes, see if this solves the problems?
source to share