简体   繁体   English

Azure AD B2C 密码更改自定义策略,用户每次都需要登录

[英]Azure AD B2C password change custom policy, user needs to sign in every time

I've implemented the password change custom policy according to the documentation and use msal.js on the frontend to start the password change flow.我已经根据文档实现了密码更改自定义策略,并在前端使用 msal.js 来启动密码更改流程。 This works accept that the user needs to sign in again although the user is already signed in to the application.尽管用户已经登录到应用程序,但此工作接受用户需要再次登录。 So it asks the user credentials every time.所以它每次都会询问用户凭据。 Why isn't B2C detecting that the user has already signed in and how can I solve this?为什么 B2C 没有检测到用户已经登录,我该如何解决? Thanks!谢谢!

MSAL.js is setting the prompt parameter, therefore, forcing B2C to ignore the cookie, therefore, forcing the sign-in. MSAL.js正在设置提示参数,因此,强制 B2C 忽略 cookie,因此,强制登录。

const urlNavigate = authenticationRequest.createNavigateUrl(scopes) + "&prompt=select_account" + "&response_mode=fragment";

Source 来源

You can verify this by taking the URL MSAL.js redirects the user to and removing the prompt query parameter.您可以通过获取 URL MSAL.js 将用户重定向到并删除提示查询参数来验证这一点。


Related GitHub Issue: Allow Controlling the prompt parameter .相关 GitHub 问题: 允许控制提示参数 We need to convince the MSAL library owners we need control over this parameter.我们需要说服 MSAL 库所有者我们需要控制此参数。

If you are trying to test through the B2C Custom Policies "Run now" endpoint, just remove the &prompt=login query parameter from the link.如果您尝试通过 B2C 自定义策略“立即运行”端点进行测试,只需从链接中删除&prompt=login查询参数。 If you are already logged in it will skip the login, if you are not, it will still prompt for your credentials.如果您已经登录,它将跳过登录,否则,它仍会提示您输入凭据。

Credit to Jas Suri: Azure B2C EditProfile custom policy without Signing In first 感谢Jas Suri: Azure B2C EditProfile 自定义策略,无需先登录

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM