【问题标题】:Msal-angular always opens popup while I prefer redirection当我更喜欢重定向时,Msal-angular 总是打开弹出窗口
【发布时间】:2020-04-01 22:02:09
【问题描述】:

在我的 app.module.ts 中,我有 msal-angular 的配置:

imports: [
 BrowserModule.withServerTransition({ appId: 'ng-cli-universal' }),
  HttpClientModule,
  FormsModule,
  RouterModule.forRoot([
    { path: '', component: HomeComponent, pathMatch: 'full' },
    { path: 'ms-profile', component: MsProfileComponent, canActivate: [ MsalGuard ] }
  ]),
  RouterModule,
  MsalModule.forRoot({
    auth: {
      clientId: '7be72f7e-2433-4ef8-b1c7-9b1c91514659',
      authority: 'https://login.microsoftonline.com//d566b150-219d-4312-ba59-3dca2f84a2ac',
      validateAuthority: true,
      redirectUri: 'http://localhost:4200/',
      postLogoutRedirectUri: 'http://localhost:4200/',
      navigateToLoginRequestUrl: true
    }
  }
)
]

通常(根据文档)我应该重定向到 aad(Azure Active Directory)的登录页面,但我总是会收到一个弹出窗口。在这种情况下,我想通过重定向进行身份验证。

【问题讨论】:

    标签: angular msal


    【解决方案1】:

    显然这不是配置问题,而是我登录用户的方式:

    login() {
        this.authService.loginRedirect();
        // const isIE = window.navigator.userAgent.indexOf('MSIE ') > -1 || window.navigator.userAgent.indexOf('Trident/') > -1;
    
        // if (isIE) {
        //   this.authService.loginRedirect();
        // } else {
        //   this.authService.loginPopup();
        // }
      }
    

    由于在我的情况下isIE 是假的,所以它进行了弹出登录。

    【讨论】:

    • 我也注释掉了,但它仍然会打开弹出窗口
    猜你喜欢
    • 1970-01-01
    • 2023-04-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-09-20
    • 1970-01-01
    相关资源
    最近更新 更多