I have an app with login page and other pages that availibale after authentication. The problem is that other pages have side menu. Side menu must been placed in root template(app.html) with
ion-nav and controled via
MenuController. Is there other way to setup menu? I mean skip this nasty playing with
enabled/disable for Login. Also that couse a lot of troubles for me becouse in my side menu i have a component that connects to backend for some data and this data is requires auth token. So I use some kind of hacks to disable loading from backend before authetication just becouse the sidemenu is always up.
I store auth token in storrage for futher usage. So when user relaunch app he can work without auth. But before app checked all the sruff he or shee see a page that set as root. So what is best practice to skip somekinf of blinking for pages that user shoudnt see. For how I’ve set a blank page as root. But I dont think that is a best practice.
Thank you and sorry for my poor English skills.
I think the way to disable - enable/disable the sidemenu is fine.
For the sending of the request it is correct to simply check, if you are logged in.
Therefore you could add a Subject to your authservice, where you inform all app parts if you are logged in.
e.g. the request needed for your sidemenu is only send if the value of the Subject in your auth service is set to true.
(Search for Subject, Observables ;))
If you start your app --> manually hide you splash screen.
In the meantime you can read the storage if loggedin --> set the new root.
PS: never excuse for poor english skills… if you get answers, the users are willing to read and understand it ;).
Thank you. But my app mostly is for web that whay i decide to use this trick with ‘blank page’.
PS: I lahve a fear that peope will not understand me
in case of the blank page: Show a loading overlayer at the startup?
If people do not understand you, they will tell you or ask for more/better information, description, what ever.
As long as you can say to your self, i am trying my best it is okay i think…
Yes, I’ve alredy put overlay. Just wonder maybe there is other ways
Thank you for help
If you look at the conference app, it has an example of a dynamic side menu. You can use that structure to show different options based on authentication status: for example, all your ordinary options when authenticated, and [“Login”, “Register”] when not.