reactjs - 如何使 'forgot password' 在带有 Azure AD B2C 的 React-aad-msal 中工作?

标签 reactjs azure azure-active-directory adal adal.js

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

enter image description here

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

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

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/

相关文章:

c# - Microsoft.Azure.Documents.DocumentClientException : Server could not parse the Url

c# - Azure 信息保护/权限管理服务 SDK 2.1 - 无法启用文档跟踪

google-chrome - 浏览器如何处理OAuth2中的redirect_uri?

javascript - 在选择输入中检索 option.id 而不是 option.name

reactjs - 如何在创建 react 应用程序中添加谷歌验证码?

reactjs - 当元素处于内部条件时如何使用 useRef?

c# - 如何在 Azure 搜索中允许自定义分析器使用通配符

reactjs - 如果ReactJS状态具有map属性,则更改map值不会反射(reflect)状态

android - 独立 PWA 中断登录

c# - 术语 'Connect-AzureAD' 未被识别为 cmdlet 的名称