-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Timing issue in isLoggedIn #294
Comments
Hmm, what might be happening is that the currentUser object hasn't been returned from the server by the time that function is called. Maybe a solution would to have isLoggedIn return a promise based on requesting the currentUser, and only redirect after that's been resolved. |
I had the same problem when programming authentication on my application... I had to make my auth service return a promise to check the validity of the current session. |
I have the same problem. |
Looking at how the auth service is setup, what I did was use getCurrentUser() instead of isLoggedIn(), and run the check on the property in the $promise of the returned object (actually inside that $promise you can safely use isLoggedIn ) , as far as I can tell this works until a better solution is provided. An extra check to make sure getCurrentUser didn't give us undefined was needed. It might not be the best, but is something. |
in app.js
Auth.isLoggedIn is returning false when the app is first run and the user is already logged in. Only when you switch state a second time does the function return true as the currentuser has then been set in the auth service. Could there is a timing issue of some sort?
The text was updated successfully, but these errors were encountered: