我正在使用react-aad-msal使用 Azure AD B2C。我可以正常登录和退出。但是,当我单击“忘记密码?”时,身份验证窗口消失并且没有任何反应。
我似乎需要指定“忘记密码”策略的名称,但我不知道该把它放在哪里。
根据托尼的回答,将此代码添加到我的应用程序的渲染中:
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}
/>;
}
我看到,在单击“忘记密码?”后,条件为 true,并且发生返回。但是,密码重置窗口没有显示,我被重定向回我的应用程序 URL。
有什么建议吗?
最佳答案
我所做的是在我的 App.js 中创建一个路由:
<Route
path="/forgot"
component={() => {
window.location.href = forgotPasswordUrl;
return null;
}}
/>
然后,在构造函数
if (window.location.hash.indexOf('AADB2C90118') >= 0) {
history.push('/forgot');
}
这有效。
关于reactjs - 如何使 'forgot password' 在带有 Azure AD B2C 的 React-aad-msal 中工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55718030/