我目前在我的authguard中有以下代码,以防止未登录时访问路由,但我还希望将未经验证的用户发送到验证页面,我该怎么做?
canActivate(): Observable<boolean> {
return Observable.from(this.auth)
.take(1)
.map(state => !!state)
.do(authenticated => {
if (!authenticated) this.router.navigate(['/login']);
})
}
1 回答
您可以检查
emailVerified
属性的值:注意 . 您的代码中的
this.auth
可能已经是一个可观察的 . 无需将其包裹在Observable.from()
中 .