How to implement login / logout flow?

I’m new to ionic and trying to make a login and logout flow ,

This is the structure


LoginPage => TabsPage


TabsPage => LoginPage

I’m currently implementing logging out with this.navCtrl.setRoot(LoginPage);
It sets the LoginPage as Root but on clicking Hardware Back button , the LoginPage is dismissed and I can still see the TabsPage which is active in the background.

How do I solve this ?

Have a look at this: