使用 Angular Firebase 库 angularfire 获取用户的 MultiFactorAuth 属性

问题描述 投票:0回答:1
我使用 Firebase 作为我的 Web 应用程序的用户数据库。由于我使用 Angular (16) 并且有一个来自 Angular 的官方库/包装器:

https://github.com/angular/angularfire/

这个库的文档并不是那么理想,在我的网络应用程序中,我试图查明登录的用户是否启用了任何多因素身份验证。我不是在登录过程中谈论,而是在一般情况下谈论。在普通的 firebase 上,用户有一个名为“multiFactor”的属性,该属性在该库的用户中不存在。

现在的问题是,我如何访问用户的 multiFactor 状态?希望我提供了足够的信息。

谢谢大家。

我尝试的只是检查我通过身份验证获得的用户对象并检查身份验证和用户的所有属性

angular firebase angularfire2 angularfire multi-factor-authentication
1个回答
0
投票
因此,一旦用户登录,您需要从当前用户创建一个 multiFactorUser。

import * as firebase from '@angular/fire/auth'; constructor(private authentication: firebase.Auth) { } public async register() { const currentUser = this.authentication.currentUser; if (currentUser) { const multiFactorUser = firebase.multiFactor(currentUser); const multieFactorSession = await multiFactorUser.getSession(); } }
    
© www.soinside.com 2019 - 2024. All rights reserved.