Open Closed

How to pass __tenant as query param or header param through angular UI login button click? #1052


User avatar
0
sergei.gorlovetsky@gmail.com created

ABP Framework version: 4.2.0 UI type: Angular Identity Server Separated: yes.

I'm capable of resolving the tenant on my UI - {0}.mydomain.com then all the requests have a __tenant param, but when I click the login button of my Angular UI, the app is redirected to the endpoint identityserver.mydomain.com/Account/Login and the __tenant param on the header isn't present anymore. My need is to pass the __tenant param to identify the tenant on the identity server.

How can this be achieved? Is it through the UI? Is there another way to identify the tenant on the identity server?


2 Answer(s)
  • User Avatar
    0
    Mehmet created

    Hi

    The tenant id cannot be added to the header while redirecting to the login page. Because, in the authorization code flow, the angular-oauth2-oidc package is using below code to redirect:

    location.href = uri;
    

    However, you can send the tenant id as a query parameter like this:

    import { OAuthService } from 'angular-oauth2-oidc';
    import { MultiTenancyService } from '@abp/ng.core';
    
    export class MyComponent {
    constructor(
        private oAuthService: OAuthService,
        private multiTenancyService: MultiTenancyService
      ) {};
    
      login() {
        this.oAuthService.initCodeFlow(null, { tenant: this.multiTenancyService.domainTenant.id }); // navigates to IdentityServer login page
      }
    }
    
  • User Avatar
    0
    sergei.gorlovetsky@gmail.com created

    Thank you Mehmet! A passed a __tenant parameter and this solved the proposed issue.

Made with ❤️ on ABP v8.2.0-preview Updated on March 25, 2024, 15:11