如何使用 Azure AD B2C 在 react-aad-msal 中使用“忘记密码”?

pol*_*a-c 6 azure reactjs azure-active-directory adal adal.js

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

在此处输入图片说明

似乎我需要指定我的“忘记密码”策略的名称,但我不知道把它放在哪里。

根据 Tony 的回答,将此代码添加到我的应用程序的渲染中:

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}
    />;
    }
Run Code Online (Sandbox Code Playgroud)

我看到在我点击“忘记密码?”后,条件为真,返回发生。但是,密码重置窗口没有出现,我被重定向回我的应用程序 URL。

有什么建议?

ism*_*tim 2

我所做的是在 App.js 中创建一个路由:

          <Route
            path="/forgot"
            component={() => {
              window.location.href = forgotPasswordUrl;
              return null;
            }}
          />
Run Code Online (Sandbox Code Playgroud)

然后,在 constructor

if (window.location.hash.indexOf('AADB2C90118') >= 0) {
  history.push('/forgot');
}
Run Code Online (Sandbox Code Playgroud)

那行得通。