Ionic Application redirects after application minimizes bug


#1

I encountered a new problem/bug in my application here’s the scenario:

How can I prevent the application to redirect to a certain page since I have this piece of code in my app.component.ts?

const authObserver = afAuth.authState.subscribe( user => {
      if (user) {
        this.rootPage = HomePage;
        authObserver.unsubscribe();
      } else {
        this.rootPage = LoginPage;
        authObserver.unsubscribe();
      }
    });

This is the part where it goes wrong:

After logging in -> user is forced to take the test but then, the user minimizes without finishing the test and after resuming the application -> User is redirected to the homepage without even submitting the test

At the homepage, you should have a data in your firebase regarding the score you’ve accumulated in the test but since you did not submit the test I’m having undefined, how can I prevent this?


#2

Not sure if related, but why are you unsubscribing after one emission? Isn’t there a logout feature?