I’m trying to follow along with the Ionic 2 guide, however I can’t work out how you’re meant to check whether the user is actually authenticated on startup, or after login.
For example, auth.login()
has no callback, so you don’t know whether it was a success or not.
However, my issue is with authenticated()
. It returns a value based on this.idToken
, however if you call authenticated()
too soon after startup, it won’t have fetched that value from local storage so returns false. For example, doing the following inside app.component
won’t work as this.idToken
is still null at this point:
if (auth.authenticated()) {
self.rootPage = TabsPage
}
I want to watch the authentication state and update the rootPage on change, however I can’t see any way to do this.