I am using firebase with firebase authentication to log in & authenticate users.
There seems to be a bit of redundancy and I’m not sure how to best structure this.
I have in my global “page” on app load - a Get the Current User - and if they’ve authenticated but have simply refreshed the app, it stores the uid & fetches & gets the idToken for API calls and dismisses the initial view.
Then I have the same replicated on successful sign up. It creates a user, adds them to my database, gets their uid & fetch token & dismisses initial view.
Then there’s the successful sign in. The new user created I still gotta fetch their details & add the tokens to the app variables so that API calls can function.
And finally - there’s another one which is on page load of the sign in page because users can be directed there if their tokens are expired or they may get redirected and I gotta basically check again the user status & get & fetch tokens & dismiss initial view.
It seems really a lot! I’m wondering if I’m missing something?? Is there a good tutorial for a comprehensive signin/user management flow? A lot of the tutorials I found are just for the basic implementation
I would not add the get current user flow to the global canvas. As the initial view is the first page the app opens on launch. And there you already have the get current user flow.
As for the appearing spinners I would suggest placing the hide spinner flow at the end of the get current user if that user is not logged in.
If it is logged in I would keep the spinner spinning and dismiss initial view and hide the spinner on the next page.
If the user was not logged in hide the spinner there and the user will log in with the regular login view.
I have not found any comprehensive signup/login tutorials but You can check out these custom http requests for some useful logic flows. I do plan to create a tutorial in the future but have no time estimate for that yet.
Oh and one more note. You don’t need to duplicate your set token to app variable flows but instead you can have both the get current user and login user flows connected to the set app variable. And inside the binding use IF(IS_EMPTY(outputofgetcurrentuser), outputofloginuser.tokenId, outputofgetcurrentuser.tokenId)