如何使用 Azure AD B2C 在 react-aad-msal 中使用“忘记密码"? [英] How do I make 'forgot password' working in react-aad-msal with Azure AD B2C?
本文介绍了如何使用 Azure AD B2C 在 react-aad-msal 中使用“忘记密码"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
I am using react-aad-msal with Azure AD B2C. I have sign-in and sign-out working. However, when I click 'Forgot your password?', the auth window disappears and nothing happens.
It seems I need to specify name of my 'forgot password' policy, but I do not know where to put it.
Based on Tony's answer added this code to my App's 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}
/>;
}
I see that after I click "Forgot password?", the condition is true, and return happens. However, the window for password reset does not show up and I get redirected back to my app URL.
Any suggestions?
解决方案
What I did was create a Route in my App.js:
<Route
path="/forgot"
component={() => {
window.location.href = forgotPasswordUrl;
return null;
}}
/>
Then, in the constructor
if (window.location.hash.indexOf('AADB2C90118') >= 0) {
history.push('/forgot');
}
And that works.
这篇关于如何使用 Azure AD B2C 在 react-aad-msal 中使用“忘记密码"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文