@brassier wrote:
I have a common set of code that runs on ionViewCanEnter, which checks if a user is logged in before displaying secure pages. This seems to work...on the surface.
When a user isn't logged in, there is a split second where the page is seen before it navigates to the non-authenticated page. I can also see that the page load does get executed (ionViewDidEnter does fire). The page access is blocked...eventually. How can I prevent the page load from executing, and prevent the page from being displayed for a split second? Here's my common implementation of ionViewCanEnter.
ionViewCanEnter() { this.loggingService.debug("securePage: ionViewCanEnter"); this.auth.hasLoggedIn().then((loggedIn) => { if (!loggedIn) { this.loggingService.error("Blocked a page view - user not logged in"); this.events.publish(Constants.EVENT_LOGOUT, true); return false; } //Good to go return true; }).catch((error) => { this.loggingService.error("Secure Page: error getting loggedin status: " ,error); this.events.publish(Constants.EVENT_LOGOUT, true); return false; } ); }
Posts: 2
Participants: 2