Friday 21 December 2018

Issues with login and authentication in PASSPORTJS

Hey guys :)I am having some issue with my application. I have two different logins in this application, and I am using passportjs and express-session to handle it. However, I am having some issues:One login refers to a model called "user". This login works perfectly.The other one, is a model called "employees". I made the "employees" routes a mirrored version of the "user" routes, since the "user" is working fine.The "employees" login works fine, but, after the login, req.isAuthenticated() is false (it means, login is not working that fine lol), then, req.user is undefined. I don't have this issue when I do the login for the "user".I have created two different strategies for each model, and two different instancies of passport to handle each of them; It still does not work properly.Here are some images from my code:App config related to passport and the models. I have two strategies for each one, as well as two instancies of passport.​Passport configuration​User model​Employee model​User register and login routes. This one works perfectly. No problems at all! (ignore the get route for /protected, that was made only for tests...)​This is the employee register and login routes. The registering is working fine, but not the login. After I do the login, it is like nothing happened at all...​Thank you guys for the attention! I have been struggling with it for some days, and not even stackoverflow could help me on this.. I think that it is something either with the passport configuration or in the post route at my employees login.​Any help is appreciated​I wish you the best​

Submitted December 21, 2018 at 10:29AM by SEXYBRUISER

No comments:

Post a Comment