TypeError:注销时无法读取null的属性'uid'

时间:2019-02-10 08:05:54

标签: ionic3 angularfire2

我是Ionic和AngularFire的新手。每次我注销用户时,都会显示错误消息“无法读取null的属性'uid”。我想我只需要检查用户是否已登录,但是我不知道如何登录。请帮忙。

这是我的登录功能:

async login(user: User) {
try {
     this.afAuth.auth.signInWithEmailAndPassword(user.email, user.password)
     .then(tawo => {
            this.profileRef = this.afDatabase.object('/profile/' + tawo.user.uid)
            this.resUser = this.profileRef.valueChanges();
            this.resUser.subscribe(res=> {
                  if(res == null) {
                      this.navCtrl.setRoot('RegisterprofilePage');
                  }
                  else{
                      this.navCtrl.setRoot('TabsPage');
                  }
            })  
      })

}
catch(e){
    console.error(e);
}

这是我的注销功能:

logout() {
    this.afAuth.auth.signOut();
    this.app.getRootNavs()[0].setRoot('LoginPage');
}

0 个答案:

没有答案