You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In my controller setup code, I sometimes need to access the user object (e.g. using $auth.user.id to send as a parameter to a backend API). On occasion, it seems like the user object isn't populating since the backend API call seems to be missing that parameter.
Is this expected behavior? If so, what's the right way to access the user object at the right time? I know that one option might be to add validateUser as a state resolve, but that blocks the transition until the promise is finished. I prefer to transition to the page immediately and have a "loading...." indicator rather than causing any delay. But then this means I need some way of waiting for the validateUser to finish inside my controller logic. Any advice? Thanks!
The text was updated successfully, but these errors were encountered:
As a general rule, I recommend the resolver strategy as it will be less problematic, but if you're looking to begin the transition immediately, you may wish to setup a watch expression on $rootScope.user which ng-token-auth sets upon successful validation / login. Either that, or listen to the auth:login-success and auth:validation-success events.
Hope this helps. Please let me know if you need to re-open this issue!
In my controller setup code, I sometimes need to access the user object (e.g. using $auth.user.id to send as a parameter to a backend API). On occasion, it seems like the user object isn't populating since the backend API call seems to be missing that parameter.
Is this expected behavior? If so, what's the right way to access the user object at the right time? I know that one option might be to add validateUser as a state resolve, but that blocks the transition until the promise is finished. I prefer to transition to the page immediately and have a "loading...." indicator rather than causing any delay. But then this means I need some way of waiting for the validateUser to finish inside my controller logic. Any advice? Thanks!
The text was updated successfully, but these errors were encountered: