node.jspassport.jsejsexpress-sessionpassport-local-mongoose

The user registers he's authenticated but cant get to the secret page so it redirects me to the login always


I do not actually know where the problem is but what i think is in either the secrets route or register route. I want in that if the user registers the cookie is saved with the session id and the user is authenticated automatically so as he can access the secrets page on immediate register and on login. it seems as if the user is never authenticated

This image is for my register route This image is for my secrets route


Solution

  • As per your code, if it is redirecting to /login, then the method isAuthenticated() is failing. Do check the code is isAuthenticated. Also make sure that the method exists.