reactjs - 放大和反应:代码不匹配和失败启用软件令牌 MFA
问题描述
我有一个 Cognito 用户池,它的 MFA 设置为 Optional,仅 TOTP。
我正在尝试设置一个页面,在此AWS 文档之后首次为用户启用 MultiFactorAuthentication 。
当我的组件安装时,我生成一个二维码并使用 qrcode.react 在屏幕上显示它
useEffect(() => {
Auth.currentAuthenticatedUser({ bypassCache: true }).then(user => {
setUser(user);
Auth.setupTOTP(user).then(code => {
const authCode = "otpauth://totp/AWSCognito:" + user.username + "?secret=" + code + "&issuer=Invent";
setQrCode(authCode);
});
});
}, []);
然后,当用户输入输入时,我对其进行验证并调用 setPrefferredMFA。现在在这里,我检查了“输入”是否正确传递并且那里没有问题。
const setupMFA = input => {
Auth.setupTOTP(user).then(() => {
Auth.verifyTotpToken(user, input)
.then(() => {
Auth.setPreferredMFA(user, "TOTP").then(() => {
props.setShowModal(false);
});
})
.catch(e => {
// Token is not verified
});
});
};
我仍然收到代码不匹配和无法启用软件令牌 MFA错误并且无法为用户设置 MFA。
解决方案
我解决了。
Auth.verifyTotpToken() 不应该在 setupTOTP 的 .then() 块中。
噗。删除 setupMFA 函数中的 Auth.setupTOTP 使其工作。
推荐阅读
- c# - 如何初始化树节点以进行调试?
- shopify - 客户响应 JSON 中 Shopify CustomerID 的最大长度是多少
- mongodb - mongodb currentop 输出“secs_running”、“microsecs_running”值不匹配
- python - 如何在python中有效地组合断开的csr矩阵?
- java - 曼宁出版的骆驼行动
- unicode - 使用 Barcode4J MessagePatternUtil 解析 € 时遇到问题
- python - MySQL:如果不存在则创建新列并将已存在列的值复制到 Python 中新创建的列
- flutter - UI 和 HTTP 调用的 Flutter 集成测试
- c - 使用 alignof 打包两个对象
- c# - 只有在 .NET Core 2.2 中提供密码后,才能动态提供某个文件夹中的所有文件