I am new to ionic app development. I have Implemented the login and logout logic like below.
Login in login.ts
loginUser(){
if (!this.loginForm.valid){
console.log(this.loginForm.value);
} else {
this.authData.loginUser(this.loginForm.value.email, this.loginForm.value.password)
.then( authData => {
this.navCtrl.setRoot(TabsPage);
}, error => {
this.loading.dismiss().then( () => {
let alert = this.alertCtrl.create({
message: error.message,
buttons: [
{
text: "Ok",
role: 'cancel'
}
]
});
alert.present();
});
});
this.loading = this.loadingCtrl.create({
dismissOnPageChange: true,
});
this.loading.present();
}
}
Logout in home.ts
logout(){
this.authData.logoutUser()
.then((user) => {
let alert = this.alertCtrl.create({
message: "You are logging out",
buttons: [
{
text: "Ok",
role: 'cancel',
handler: () => {
this.navCtrl.setRoot(LoginPage);
this.navCtrl.popToRoot();
}
}
]
});
alert.present();
}, (error) => {
var errorMessage: string = error.message;
let errorAlert = this.alertCtrl.create({
message: errorMessage,
buttons: [
{
text: "Ok",
role: 'cancel'
}
]
});
errorAlert.present();
});
}
The firebase authentication works properly. The issue here is when logging in I am setting the TabsPage as the root.
Then in logout
this.navCtrl.setRoot(LoginPage);
this.navCtrl.popToRoot();
**After logout the login page appears and the tabs are also appearing in the LoginPage. How can I solve this?**