gpt4 book ai didi

angular-oauth2-oidc 忘记密码流程

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

我正在使用 angular-oauth2-oidc 在我的 Angular (8) 应用程序上设置 B2C。
我有一个登录和退出策略,并且我已经成功地设置了 angular-oauth2-oidc 服务。
目前我正在使用包含忘记密码链接的标准 Microsoft 登录页面。
我已经为 B2C 中的忘记密码创建了流程,但我正在努力将其集成到 angular-oauth2-oidc 中。
当我单击忘记密码链接时,B2C 抛出错误“AADB2C90118”;为确保流程正确,我测试了创建 AuthConfig 文件的流程,例如我为登录策略创建的文件;只需使用忘记密码的流程信息(在这种情况下,用户单击一个按钮并被重定向到忘记密码的颁发者) - 它就可以工作。

AuthConfig 文件中是否有任何变量可以设置为忘记密码端点或任何可以处理此问题的方法?

最佳答案

我按照 angular-oauth2-oidc 库的创建者的建议设法让它工作。
首先,我创建了一个 OAuthErrorEventParams 接口(interface),我可以将 OAuthErrorEvent.params 转换为:

export interface OAuthErrorEventParams {
error: string;
error_description: string;
state: string;
}
然后我创建了这个常量来表示我的 RedirectUrl 以重定向到密码重置流程:
export const PasswordResetUrl = 'https://[tenantname].b2clogin.com/[tenantname].onmicrosoft.com/oauth2/v2.0/authorize?' +
'p=[PasswordResetFlowName]' +
'&client_id=' + authConfig.clientId +
'&nonce=defaultNonce' +
'&redirect_uri=' + window.location.origin + '/index.html' +
'&scope=openid' +
'&response_type=id_token' +
'&prompt=login';
最后,在我处理 Auth 服务的设置和配置的组件中,我添加了以下内容:
constructor(private oauthService: OAuthService) {
this.configure();
this.oauthService.events.subscribe(e => {
if (e instanceof OAuthErrorEvent) {
const parm = e.params as OAuthErrorEventParams;
if (parm.error === 'access_denied' && parm.error_description.includes('AADB2C90118')) {
// redirect to forgot password flow
window.location.href = PasswordResetUrl;
} else if (parm.error === 'access_denied' && parm.error_description.includes('AADB2C90091')) {
// user has cancelled out of password reset
this.oauthService.initLoginFlow();
}
}
});
this.oauthService.tryLoginImplicitFlow();
}
我真的希望这对某人有所帮助,因为在登陆之前我花了很长时间找到解决方案。

关于angular-oauth2-oidc 忘记密码流程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60345068/

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