首页 > 解决方案 > 从角度组件在 microsoft-adal-angular6 中添加一个 extraQueryParameter login_hint

问题描述

使用以下包https://www.npmjs.com/package/microsoft-adal-angular6我登录到 azure AD。在应用程序模块中,我使用如下的 extraQueryParamter 及其工作。

MsAdalAngular6Module.forRoot({`
      tenant: "xxxxxx.onmicrosoft.com",
      clientId: "xxxxxxxxxxxxxx",
      redirectUri: window.location.origin + '/home',     
      navigateToLoginRequestUrl: false,
      postLogoutRedirectUri: window.location.origin,
      cacheLocation: 'localStorage',
      extraQueryParameter: 'login_hint=abc@xyz.com'
    }),

但是我正在尝试找出如何从组件传递这个 extraQueryParameter: login_hint=abc@xyz.com' (在单击按钮的登录组件页面中,我正在重定向到受路由中的 authencationguard 保护的 URL)。有没有这样做。我无法在 app 模块中预设 login_hint。

标签: angularazure-active-directoryangular6adaladal.js

解决方案


在该库的源代码中,我在服务文件中添加了另一个函数。

public login_userhint(loginid: string) {
    this.context.config.extraQueryParameter = 'login_hint=' + loginid;
    this.context.login();
  }

在 MsAdalAngular6Service 中。

这解决了我的问题。


推荐阅读