How correctly disable previous pages after user registration?

Hi!

I’m using cordova + f7. I want to disable previous pages after user login/registration.
I try this way:

beforeLeave: function (routeTo, routeFrom, resolve, reject) {

      var index;
      if (mainView.router.history.length > 1){
        index = mainView.router.history.length - 2;
      } else {
        index = 0;
      }

      if ( routeTo.url != mainView.router.history[index] ) {
        resolve();
      } else {
        reject();
      }
      
    }

It works fine when I click back button the first time. The page doesn’t change, but url changes to index.html. And I can see splash screen when I click back button second time.
How can I prevent app reloading?

Br,
Alex.

Do you use pushState? You should disable it as there is no way to prevent browser history.
If not, i can recommend to go away from splash/login screen to user content with passing reloadAll: true parameter like router.navigate('/home/', { reloadAll: true }) or by adding data-reload-all="true" attribute to such link. It will remove all previous pages from history

1 Like

oh… I tried reloadAll, but I totally forgot about pushState. I will disable it and try again. Thank you very much!