reactjs - React SPA Azure ADB2C 密码重置用户流程
问题描述
我正在关注带有 msal 和 AADB2C 的 React 示例。
reset password flow
如果用户在我的流程中单击“忘记了我的密码”,我想运行signIn
。从这里我看到我需要处理这种情况:
if (event.eventType === EventType.LOGIN_FAILURE) {
if (event.error && event.error.errorMessage.indexOf("AADB2C90118") > -1) {
if (event.interactionType === InteractionType.Redirect) {
instance.loginRedirect(b2cPolicies.authorities.forgotPassword);
} else if (event.interactionType === InteractionType.Popup) {
instance.loginPopup(b2cPolicies.authorities.forgotPassword)
.catch(e => {
return;
});
}
}
}
并且forgotPassword
权限是一个URL https://tenantName.b2clogin.com/tenantName.onmicrosoft.com/B2C_1_PasswordReset
,例如。尽管我正在关注这些示例和文档,但我遇到了这个问题,似乎没有任何提及或解决方案:
未处理的拒绝(TypeError):无法在字符串“https://tenantName.b2clogin.com/tenantName.onmicrosoft.com/B2C_1_PasswordReset”上创建属性“authenticationScheme”
解决方案
您在控制台中收到错误:未处理的拒绝(TypeError):无法在字符串上创建属性“authenticationScheme”
您收到此错误是因为您在代码中的某处使用了“authenticationScheme”,但在阶段“authenticationScheme”对象为空或未定义。
更新您的代码:
if (authenticationScheme) {
do something here.
}
如果 authenticationScheme 为 null 或未定义,则更新后,它将不会在 null 或未定义的对象上执行代码。