gpt4 book ai didi

angular - 当我使用 Azure 静态 Web 应用程序时,为什么 msal-angular `loginPopup` 会弹出它自己的页面

转载 作者:行者123 更新时间:2023-12-02 07:20:20 38 4
gpt4 key购买 nike

当我调用“msal-Angular”的MsalService.loginPopup时,它自己的页面会像这样弹出。 enter image description here

当我从自定义登录并尝试从默认域(从 Azure 静态 Web 应用程序发布)登录时,会发生这种情况

import { Inject, Injectable } from '@angular/core';
import { MsalService } from '@azure/msal-angular';
import { LOGIN_REQUEST_TOKEN, LoginRequest, TOKEN_REQUEST_TOKEN, TokenRequest } from './config';
import { defer, from, Observable, of } from 'rxjs';
import { AuthResponse } from 'msal';
import { isIE } from './isIE';

export function checkClientLogin(): boolean {
return !!localStorage.getItem('isLogin');
}

const extraScopesToConsent = [ 'user.read', 'openid', 'profile' ];

@Injectable()
export class MsalAuthService {

constructor(
private msalService: MsalService,
) {
}

login(): Observable<AuthResponse> {
return defer(() => {
if (isIE) {
return this.msalService.loginRedirect({extraScopesToConsent});
} else {
return from(this.msalService.loginPopup({extraScopesToConsent}));
}
});
}

}

最佳答案

当您在代码中使用 msal-Angular 并对自己进行身份验证时,将出现另一个弹出窗口,将您重定向到 login.microsoftonline.com。正如您的代码中提到的,当需要弹出和需要重定向时会声明它。

Azure 静态应用程序支持带有模型对话框的 loginPopUp。了解有关 Azure 静态 Web 应用和模型对话框的更多信息:

https://learn.microsoft.com/en-us/azure/static-web-apps/

https://learn.microsoft.com/en-us/azure/devops/extend/develop/using-host-dialog?view=azure-devops

关于angular - 当我使用 Azure 静态 Web 应用程序时,为什么 msal-angular `loginPopup` 会弹出它自己的页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67998252/

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