gpt4 book ai didi

azure-ad-b2c - Azure AD B2C 自助服务密码重置链接不起作用

转载 作者:行者123 更新时间:2023-12-03 13:27:26 27 4
gpt4 key购买 nike

关闭。这个问题需要details or clarity .它目前不接受答案。












想改善这个问题吗?通过 editing this post 添加详细信息并澄清问题.

10 个月前关闭。




Improve this question




我已经能够为我正在测试的租户正确设置注册/登录策略。我已经设置了重置密码属性以允许每个人使用他们的电子邮件重置他们的密码。目前,用户使用他们的电子邮件(也是他们的用户名)、名字和姓氏进行注册。

但是,当我单击登录页面上的“我忘记了密码”链接时,它只会将我重定向回同一页面。有什么我在这里想念的吗?

最佳答案

Azure AD B2C 中有两种不同的密码重置机制:

  • 登录政策 :应用程序不需要任何工作,单击“我忘记了密码”会自动将用户重定向到通用的 Microsoft 品牌密码重置页面。
  • 注册/登录政策 :这需要应用程序做一些额外的工作 .单击“我忘记了密码”会将用户重定向回带有错误代码的应用程序。应用程序需要检测请求中的错误代码,然后进一步将用户重定向到 Azure AD B2C 密码重置策略。可以广泛自定义密码重置策略。

  • 关于如何实现第二种方法的更多细节,这里是 的代码。连接到 AuthenticationFailed 通知并重定向到您自己的 PasswordReset Controller 操作 ,来自 B2C Sign-up/Sign-in quickstart, Startup.Auth.cs

    private Task AuthenticationFailed(AuthenticationFailedNotification<OpenIdConnectMessage, OpenIdConnectAuthenticationOptions> notification)
    {
    notification.HandleResponse();

    if (notification.ProtocolMessage.ErrorDescription != null && notification.ProtocolMessage.ErrorDescription.Contains("AADB2C90118"))
    {
    // If the user clicked the reset password link, redirect to the reset password route
    notification.Response.Redirect("/Account/ResetPassword");
    }
    else if (notification.Exception.Message == "access_denied")
    {
    // If the user canceled the sign in, redirect back to the home page
    notification.Response.Redirect("/");
    }
    else
    {
    notification.Response.Redirect("/Home/Error?message=" + notification.Exception.Message);
    }

    return Task.FromResult(0);
    }

    这是代码 PasswordReset Controller 操作,它将用户重定向到密码重置 B2C 策略,来自相同的 B2C Sign-up/Sign-in quickstart, Account Controller

    public void ResetPassword()
    {
    if (!Request.IsAuthenticated)
    {
    HttpContext.GetOwinContext().Authentication.Challenge(
    new AuthenticationProperties() { RedirectUri = "/" }, Startup.PasswordResetPolicyId);
    }
    }

    为了完整起见,请务必查看 full guide/overview of setting up an Azure AD B2C Sign-up/Sign-in Policy

    关于azure-ad-b2c - Azure AD B2C 自助服务密码重置链接不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41497158/

    27 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com