我正在使用带有Azure AD B2C的react-aad-msal。我有登录和注销工作。但是,当我单击“忘记密码?”时,身份验证窗口消失,没有任何反应。

似乎我需要指定我的“忘记密码”策略的名称,但我不知道该放在哪里。
根据Tony的回答,将以下代码添加到我的应用程序的render中:
if (window.location.href.indexOf("error_description=AADB2C90118") >= 0)
{
return <AzureAD
provider={
new MsalAuthProviderFactory({
authority: 'https://login.microsoftonline.com/tfp/x5aaas.onmicrosoft.com/B2C_1_PwdReset',
clientID: 'a1568977-3095-4bf6-a6d6-c10c87658488',
scopes: ['https://x5aaas.onmicrosoft.com/ui/use'],
type: LoginType.Redirect,
postLogoutRedirectUri: window.origin,
})
}
unauthenticatedFunction={this.unauthenticatedFunction}
userInfoCallback={this.userJustLoggedIn}
authenticatedFunction={this.authenticatedFunction}
/>;
}我看到在我单击“忘记密码?”之后,条件为真,并且发生了返回。但是,密码重置窗口没有显示,我被重定向回我的应用程序URL。
有什么建议吗?
发布于 2019-06-02 03:54:38
我所做的是在我的App.js中创建一个路由:
<Route
path="/forgot"
component={() => {
window.location.href = forgotPasswordUrl;
return null;
}}
/>然后,在constructor中
if (window.location.hash.indexOf('AADB2C90118') >= 0) {
history.push('/forgot');
}这是可行的。
发布于 2019-04-17 13:37:46
在Azure B2C中使用组合注册/登录策略时,用户必须自己处理忘记密码的情况。你可以在here上找到更详细的评论。
使用本地帐户的注册或登录用户流包括“忘记密码?”链接到体验的第一页。单击此链接不会自动触发密码重置用户流。
相反,错误代码AADB2C90118将返回给您的应用程序。您的应用程序需要通过运行重置密码的特定用户流来处理此错误代码。要查看示例,请查看演示用户流链接的simple ASP.NET sample。
发布于 2020-12-30 08:29:51
通过使用msal-react和msal-browser,我能够使用以下代码获得Azure AD B2C密码重置页面(假设您创建了一个名为B2C_1_RESET的密码重置用户流):
import { useMsal } from "@azure/msal-react";
import { EventType } from '@azure/msal-browser';
....
const { instance, inProgress, accounts } = useMsal();
// MSAL Logging
//instance.setLogger(new Logger(loggerCallback));
const callbackId = instance.addEventCallback((message) => {
if (message.eventType === EventType.LOGIN_FAILURE){
if (message.error.errorMessage.includes("AADB2C90118")) { // The user has forgotten their password.
const authority = "https://<your_domain>.b2clogin.com/crowdalert.onmicrosoft.com/B2C_1_RESET";
instance.loginRedirect({authority: authority})
}
}
});https://stackoverflow.com/questions/55718030
复制相似问题