# Problems with NavController. It stops working correctly when I logout

**URL:** <https://forum.ionicframework.com/t/problems-with-navcontroller-it-stops-working-correctly-when-i-logout/130381>\
**Category:** ionic-v3\
**Created:** [May 12, 2018, 7:25pm UTC](https://forum.ionicframework.com/t/problems-with-navcontroller-it-stops-working-correctly-when-i-logout/130381 "2018-05-12T19:25:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![SergeJorge](https://avatars.discourse-cdn.com/v4/letter/s/c5a1d2/32.png) [@SergeJorge](https://forum.ionicframework.com/u/SergeJorge)\
**Post date:** [May 12, 2018, 7:25pm UTC](https://forum.ionicframework.com/t/problems-with-navcontroller-it-stops-working-correctly-when-i-logout/130381/1 "2018-05-12T19:25:49Z")

</div>

Hello, I have an ionic app with login/registration + validation and a home with a couple of views.  
The structure can be something like this:

![steps](https://global.discourse-cdn.com/ionicframework/original/3X/2/8/28642b582e4c60c6e4bfd98e6083176d29338bc4.png)

I don’t have any problem moving through the app, until I use the logout. When that happens when I register, I get to the validation page and when I get the response with the OK from the server I don’t get redirected to the home page. I also get adouble back button in my stacked views.

Maybe I am not cleaning something the right way. I don’t get any error, just everything stops working the right way. Can anybody help me with this problem?

Right now I am using Ionic 3.19.1. Just ask away if you need some more information.

This is my logout:

```auto
logout() {
        localStorage.clear();
        this.websocketService.close();
        this.close();
        this.navCtrl.setRoot('LoginPage');
        /* Testing porpose
        this.navCtrl.setRoot('LoginPage').then(() => {
            this.navCtrl.popToRoot();
        });
        */
    }

```

sms-validation.ts

```auto
import { Component } from '@angular/core';
import { IonicPage, NavController, AlertController, App } from 'ionic-angular';
import { AuthServiceProvider } from '../../providers/auth-service/auth-service';
import { NavParams } from 'ionic-angular/navigation/nav-params';

/**
 *
 * Validates the user with a sms code (To be implemented)
 */
@IonicPage()
@Component({
  selector: 'page-sms-validation',
  templateUrl: 'sms-validation.html',
})
export class SmsValidationPage {

  validated = false;
  validationCode: '';
  nickname: '';
 
  constructor(private navCtrl: NavController, private auth: AuthServiceProvider, public alertCtrl: AlertController, public navParams: NavParams, public app: App) {
     
     }
 
  public smsValidation() {
    this.auth.validateCode(this.nickname, this.validationCode).subscribe(response => {
      if (response.status) {
        this.validated = true;
        this.navCtrl.setRoot('HomePage');
        this.showPopup("Success", "Account validated.");
      } else {
        this.showPopup("Error", "Problem validating account. " + response.message);
      }
    },
      error => {
        this.showPopup("Error", error.message);
      });
  }
  
  showPopup(title, text) {
    let alert = this.alertCtrl.create({
      title: title,
      subTitle: text,
      buttons: [
        {
          text: 'OK',
          handler: data => {
            if (this.validated) {
              this.navCtrl.setRoot('HomePage');
            }
          }
        }
      ]
    });
    alert.present();
  }
  
  ionViewDidLoad() {}

}

```

app.html

```auto
<ion-nav [root]="rootPage"></ion-nav>

```

---

<div class="post-metadata">

**Author:** ![mhartington](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/mhartington/32/137757_2.png) [@mhartington](https://forum.ionicframework.com/u/mhartington)\
**Post date:** [July 19, 2021, 9:36pm UTC](https://forum.ionicframework.com/t/problems-with-navcontroller-it-stops-working-correctly-when-i-logout/130381/2 "2021-07-19T21:36:38Z")

</div>

Closed on July 19, 2021, 9:36pm UTC


