在 firebase phone 身份验证后根据用户的角色重定向用户

Redirect users depending upon their role after firebase phone authentication

我有使用 firebase-UI phone 身份验证的登录用户。如果用户是第一次登录,我会将用户重定向到 'details' 页面,如果用户是旧用户,则重定向到 'verification' 页面。但我有不同的行为。用户首先重定向到正确的页面(验证或详细信息),但随后该页面被刷新,然后重定向到主页,最后根据用户是新用户还是旧用户重定向到验证或详细信息页面。

我也收到这个警告

Navigation triggered outside Angular zone, did you forget to call 'ngZone.run()'?

warn @ core.js:33461

这是我的代码

 this.afauth.auth.onAuthStateChanged(user => {
  if(user) {
    let x = this.afauth.auth.currentUser.metadata
    console.log(x)
      if(x.creationTime == x.lastSignInTime) {
        console.log("new user")
       // this.navCtrl.navigateRoot(['details'])
        console.log(this.afauth.auth.currentUser.phoneNumber)
        let navigationExtras: NavigationExtras = {
          state: {
            user: this.afauth.auth.currentUser.phoneNumber
          }
        };
        this.router.navigate(['details'], navigationExtras);
       

      }
      else{
        console.log("old user")
      
        let navigationExtras: NavigationExtras = {
          state: {
            user: this.afauth.auth.currentUser.phoneNumber
          }
        };
        this.router.navigate(['verification'], navigationExtras);
      }
    
  }
  else {
    console.log("something wnt wrong")
  }
})

已解决。在我的 firebasui 配置中,signflow 被重定向到主页