nylo-core / nylo

Nylo is the fastest way to build your next Flutter mobile app. Streamline your projects with Nylo's opinionated approach to building Flutter apps. Develop your next idea ⚡️
https://nylo.dev
MIT License
586 stars 58 forks source link

Checking auth token externally before visiting initial route #103

Closed coreyfreeman82 closed 7 months ago

coreyfreeman82 commented 8 months ago

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?

agordn52 commented 7 months ago

Hi @coreyfreeman82,

Could you move this into the discussions page?

I can't identify an issue here with Nylo.

Thanks