# Set root page based on authentication state

**URL:** <https://community.auth0.com/t/set-root-page-based-on-authentication-state/6314>\
**Category:** Get Help\
**Tags:** auth0-lock, angular2, authentication, ionic\
**Created:** [April 21, 2017, 5:23pm UTC](https://community.auth0.com/t/set-root-page-based-on-authentication-state/6314 "2017-04-21T17:23:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![benedict](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@benedict](https://community.auth0.com/u/benedict)\
**Post date:** [April 21, 2017, 5:23pm UTC](https://community.auth0.com/t/set-root-page-based-on-authentication-state/6314/1 "2017-04-21T17:23:28Z")

</div>

I’m trying to follow along with the [Ionic 2](https://auth0.com/docs/quickstart/native/ionic2) 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.

---

<div class="post-metadata">

**Author:** ![benedict](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@benedict](https://community.auth0.com/u/benedict)\
**Post date:** [April 21, 2017, 5:25pm UTC](https://community.auth0.com/t/set-root-page-based-on-authentication-state/6314/2 "2017-04-21T17:25:18Z")

</div>

This is a more detailed question posted to SO: [http://stackoverflow.com/questions/43539492/set-root-page-if-user-logged-in](http://stackoverflow.com/questions/43539492/set-root-page-if-user-logged-in)

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [March 2, 2018, 5:53am UTC](https://community.auth0.com/t/set-root-page-based-on-authentication-state/6314/3 "2018-03-02T05:53:25Z")

</div>


