我已使用 firebase-UI 电话身份验证登录用户。如果用户首次登录,我会将用户重定向到“详细信息”页面,如果用户是旧用户,则会重定向到“验证”页面。但我的行为有所不同。用户首先重定向到正确的页面(验证或详细信息),然后该页面被刷新,然后重定向到主页,最后根据用户是新用户还是老用户重定向到验证或详细信息页面。
我也收到此警告
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 被重定向到主页
关于javascript - Firebase 电话身份验证后根据用户的角色重定向用户,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58498365/