# How to handle case where user is still authenticated they can skip login

**URL:** <https://forum.ionicframework.com/t/how-to-handle-case-where-user-is-still-authenticated-they-can-skip-login/92563>\
**Category:** ionic-v3\
**Created:** [May 31, 2017, 10:05pm UTC](https://forum.ionicframework.com/t/how-to-handle-case-where-user-is-still-authenticated-they-can-skip-login/92563 "2017-05-31T22:05:41Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![rapropos](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/rapropos/32/100227_2.png) [@rapropos](https://forum.ionicframework.com/u/rapropos)\
**Post date:** [May 31, 2017, 10:27pm UTC](https://forum.ionicframework.com/t/how-to-handle-case-where-user-is-still-authenticated-they-can-skip-login/92563/2 "2017-05-31T22:27:17Z")

</div>

I don’t really like complex interactions with the navigation system, so I avoid all of that with an `AuthService` that exposes an `authNotifier` property that is a `ReplaySubject<boolean>` with stack depth 1. In its constructor, you could do this:

```auto
constructor(storage: Storage) {
  storage.ready().then(() => storage.get('jwt'))
  .then((jwt) => {
    this.authNotifier.next(isValid(jwt));
  });
}

```

In the app component, you can do this:

```auto
constructor(auth: AuthService) {
  auth.authNotifier.subscribe((authed) => {
    if (authed) {
      this.rootPage = DashboardPage;
    } else {
      this.rootPage = LoginPage;
    }
  });
}

```

An additional benefit of this approach is that it makes logout dead easy: inject `AuthService` from anywhere and call `next(false)` on its `authNotifier`. No navigation interaction needed. Wherever you are checking and noticing that the token has expired can do this as well.

---

_[View the full topic](https://forum.ionicframework.com/t/how-to-handle-case-where-user-is-still-authenticated-they-can-skip-login/92563)._
