我正在设置 MFA 不是可选的身份验证,这意味着从注册后的第一次登录尝试开始,用户将被要求设置 MFA(在这种情况下,我将使用基于时间的一次性密码,或 TOPT) . 为此,我可以看到以下步骤是合理的:
1)通过登录表单获取用户信息 -Auth.signUp()
2)从步骤1)中检索到的用户数据确定是否已经为用户设置了基于TOPT的MFA。如果没有,请转到步骤 3),否则转到步骤 4)
3) 如果没有设置 TOPT,请重定向到将生成 QRCode 的表单以设置此 MFA 功能。验证代码后,登录用户。
4) 如果设置了 TOPT,请询问密码。验证后,登录用户。
我的困境:似乎我无法获得步骤 2) 中的信息,即是否已经为用户设置了基于 TOPT 的 MFA,而没有对用户进行身份验证。challengeName
通过步骤 1) 在有效负载中检索到的标志Auth.signUp()
仅向我提供有关是否启用 MFA ( 'MFA_SETUP'
) 的信息,而不是是否已经设置了基于 TOTP 的 MFA。为此,该方法Auth.getPreferredMFA()
可以解决问题,但它仅在传递给它的用户对象代表经过身份验证的(或已经登录的)用户时才有效。有没有办法确定是否为尝试登录(但尚未登录)的用户设置了 TOTP MFA?
此外,任何其他解决此问题的解决方案都将受到欢迎。肯定有人遇到了与我相同的情况,即从第一次登录开始就强制执行 MFA。