Azure AD B2C 与 MSAL 成功后更改重定向 URL

发布于 2025-01-19 08:03:19 字数 496 浏览 0 评论 0 原文

我有一个使用MSAL MSAL-REACT v1.3.1的React应用程序。我正在使用 loginredirect 方法将在Azure B2C中配置的预定义的用户流重定向,以重置密码。当前的行为是,当密码重置完成后,它将重定向回到该页面,该页面首先将重定向重定向到AD B2C后,该页面一旦成功完成。

当流量完成为下方之类的东西时,有没有办法更改重定向URL?

instance.loginRedirect({
    authority: `${config.authentication.authority}/${config.authentication.flow.register}`,
    redirectUri: window.location.href + '?success=true'
});

我试图设置 redirecturi Postloginredirecturi ,它似乎不会改变结果。

I have a React app which uses MSAL msal-react v1.3.1. I am using loginRedirect method to redirect a predefined user flow configured in Azure B2C for password reset. The current behaviour is that when the password reset is complete it redirects back to the page that first invoked the redirect to AD B2C once it has completed successfully.

Is there a way to change the redirect url when the flow has completed to something like below?

instance.loginRedirect({
    authority: `${config.authentication.authority}/${config.authentication.flow.register}`,
    redirectUri: window.location.href + '?success=true'
});

I have tried to set the redirectUri and postLoginRedirectUri which don't appear to change the outcome.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

漫雪独思 2025-01-26 08:03:19

redirectUrl 似乎存在限制="nofollow noreferrer">这里

重定向 URL 必须在应用程序中注册,并且不能包含通配符或查询字符串参数。

There appears to be a restriction on the redirectUrl as described here.

The redirect url must be registered with the application and cannot contain wildcards or query string parameters.

巾帼英雄 2025-01-26 08:03:19

在这种情况下,我必须做的就是在设置 msal 的位置将 navigateToLoginRequestUrl 设置为 false。具有 navigateToLoginRequestUrl 选项的代码示例:https://github.com/AzureAD/microsoft-authentication-library-for-js/issues/3818

那么也许你可以使用state 选项可将您想要的任何信息传递到返回 URL,而不是 returnURL 上的查询参数。但我不太明白这里的重点。

instance.loginRedirect({
        authority: `${config.authentication.authority}/${config.authentication.flow.register}`,
        redirectUri: window.location.href,
        state: 'success'
});

What I had to do in this situation was set the navigateToLoginRequestUrl to false where you set up your msal. Example of someone's code with the navigateToLoginRequestUrl option: https://github.com/AzureAD/microsoft-authentication-library-for-js/issues/3818

Then maybe you could use the state option to pass any information you want to the return URL instead of a query parameter on returnURL. But I don't quite see the point here.

instance.loginRedirect({
        authority: `${config.authentication.authority}/${config.authentication.flow.register}`,
        redirectUri: window.location.href,
        state: 'success'
});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文