Return to log in page on platform resume


#1

Hello. I have an app that is protected by a log in screen.
I want to show this login screen when the app is resumed, so pause and then re-focussed.
The way the log in screen works is by being the root page and when user successfully authenticates then the root page is set to the home page using navController.setRoot(view).

This is fine. I then subscribe to platform.resume and set the root again to the log in page.
This works great once. the second time the platform resume is called then the log in page is loaded twice which messes up the log in page.

How can I avoid the page running twice because I have set the root.
I tried looping over the navController entries to remove them all but remove has no effect on the entry list.
I tried popAll() to clear the list then set the root but this did nothing.
Using popToRoot will not work because my root has been set to the home page I now want it to be the log in page.

Any ideas how I can acheive this in a stable manner?

This is my info:

    @ionic/cli-utils  : 1.19.1
    ionic (Ionic CLI) : 3.19.1

global packages:

    cordova (Cordova CLI) : 8.0.0

local packages:

    @ionic/app-scripts : 1.3.7
    Cordova Platforms  : android 6.3.0 ios 4.4.0
    Ionic Framework    : ionic-angular 3.5.3

System:

    Android SDK Tools : 26.0.2
    Node              : v6.12.2
    npm               : 3.10.10
    OS                : Windows 10