-
Notifications
You must be signed in to change notification settings - Fork 482
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
reloading the page signs the user out #18
Comments
@aliwebir yeah I've been trying to get session working but there are so many implementations I'm still finding ways how is not done ;) |
@aliwebir
Hope this helps, can't believe all the time it took to do this hahaha, later! |
This helps a lot, but I think you still need to edit the cookie when the user logs out. |
@ryand626 Oh of course! I noticed that after I posted here but forgot to edit this xD |
@Beatusvir thanks for the solution! However I believe you are bypassing the register page. How does the next.templateUrl === 'views/auth/login.html' conditional work? Is that a path we set somewhere? I am trying to recreate it with register.html but cannot get it to work. |
@kunalnaik Let me check it out. I should have the code somewhere to see what I did (and if I did something about it hahahah) Edit. mmm nothing here on github, thought I forked it 😞, I'll check @ home later see what I can find. |
Hey @Beatusvir, did you find anything? |
@kunalnaik I forgot 😞 ... I added an alarm now! I'm about to head home, I should respond in about 3 hours (need to get something to eat 😄) |
@kunalnaik I can't find my modified code. All I see is some incomplete chirp code 😭. |
Darn. And yep I understood your logic, and it does work! However my thinking is that it doesn't really matter if the user is going to the login page since we are redirecting them there anyways, and rather that it is important to check if the user is attempting to go the the Register page so they can create a new account. Here is my code: `// checks for authentication on page refresh
With this, I get redirected to the login page if not auth'd. However this also applies to the register page so i am never able to create a new account :( . Any ideas? (also apologies for the weird formatting, couldn't get it right) |
Mmm can't recall, I may have done something about it but not sure. Or maybe I just got cookies working for auth and didn't even notice register wasn't working lol. It wasn't for a project or anything so not sure how far I got it. |
Oh ok, thanks for checking it out though! Do you know what the 'views/auth/login.html' path points to? Is that where you placed your login.html partial or is it something related to the authentication.js api? That's where I am most confused and don't know how to replicate it for the Register page. |
OK I figured it out. The issue was that next.templateUrl was undefined for me, and instead simply next provided the URL we wanted. So I just checked the next for 'register' instead of checking if next.templatUrl equaled the url for register. Here is my code (in case anyone else needs it):
Again, apologies for the formatting. Cheers. |
Great! 👍 Hopefully people will be able to fully implement this system because these guys just dropped that half baked code here and didn't look back. |
Good Thread..!! I initially encountered it. |
kunalnaik solution is spot on... except I couldn't get my user to ever logout. So I add some code to the sign out function to remove the cookie. After that, everything worked as intended.
|
@hwz
It seems that the sessions created in this app are not persistent and every time I reload the page, the user automatically becomes signed out. Also tried this suggestion of using
connect-mongo
module, but didn't work:http://stackoverflow.com/questions/29721225/staying-authenticated-after-the-page-is-refreshed-using-passportjs
The text was updated successfully, but these errors were encountered: