Checking auth token externally before visiting initial route #105
Unanswered
coreyfreeman82
asked this question in
Q&A
Replies: 1 comment
-
Hi @coreyfreeman82, It sounds like you need to set the Hope that helps. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am storing my user token (from my external api) in the NyStorage so that when I close the app and reopen it at a later time it can still be used without having to login again. Now the problem is that I want to set the HomePage as the initialRoute when Auth.loggedIn() returns true (in the AuthGuard) and after I have done a request to my external api to check the token. I tried to set LoginPage as the initialRoute and then in the AuthProvider I did the request and based on that result it either just goes on or redirects to the HomePage on a successful request. The problem with this is that it shows the LoginPage for a brief moment before redirecting to the HomePage. I would like to show my HomePage initially (after doing the external api call to check the token) or show the LoginPage (this can be done via a redirect) when the request is not successful. I also tried doing the request in the AuthGuard but this does not seem to be called when setting HomePage as my initialRoute and also setting routeGuards: [AuthGuard] on it. What would be the best way to do this?
Beta Was this translation helpful? Give feedback.
All reactions