【问题标题】:Redirect users depending upon their role after firebase phone authentication在 Firebase 电话身份验证后根据用户的角色重定向用户
【发布时间】:2020-02-18 06:07:49
【问题描述】:

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

我也收到此警告

导航在 Angular 区域外触发,您是否忘记调用 'ngZone.run()'?

警告@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")
  }
})

【问题讨论】:

  • verificationdetail 页面中有什么导致它刷新?
  • Nothing只有signout函数和queryparam数据

标签: javascript firebase firebase-authentication ionic4 firebaseui


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-07
    • 2018-12-16
    • 1970-01-01
    • 2016-06-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多