Open Closed

Enable linked Accounts while using custom tenant domain resolver #8427


User avatar
0
listtraderdev2 created
  • ABP Framework version: v8.1.5
  • UI Type: Angular
  • Database System: EF Core (SQL Serve)
  • Tiered (for MVC) or Auth Server Separated (for Angular): yes
  • Exception message and full stack trace:
  • Steps to reproduce the issue:

I have a custom domain tenant resolver working perfectly. Tenants have separate domains, such as tenant1.localhost:4200. The problem I have is that users can no longer use the linked accounts feature since the switch tenant option is not available on the login screen. Even when the tenant switch is available, the tenant does not get switched. There is a similar issue here, but the final solution is unavailable for reference. https://www.abp.io/support/questions/4615/Impersonate-tenant-issue-with-custom-tenant-resolver-by-sub-domain

I need to have users be able to link accounts across different tenant domains using the Linked Account feature. How can I get this to work?


18 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    You can add a new component to switch the current tenant.

    If the new tenant name exists, Replace the current URL.

    1. https://tenant1.localhost:4200 try to link a new user that belongs to tenant2.
    2. User enters a new tenant2
    3. Checkthat tenant2 exists.
    4. Replace https://tenant1.localhost:4200 with https://tenant2.localhost:4200
  • User Avatar
    0
    listtraderdev2 created

    Can you please provide me with some samples. All my authentication pages are in the HttpApi.Host project not the angular side.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Can you share a screenshot of the link login page in HttpApi.Host project?

  • User Avatar
    0
    listtraderdev2 created

    Hi.

    I dont have a custom link login page. I currently rely on the default implementation

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    ok, Can you share a screenshot of current page(include url)?

  • User Avatar
    0
    listtraderdev2 created
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    The switch tenant component will hidden if the current tenant is not resolved by cookies or query string.

    So you can override the Account layout of LeptonX theme.

    add your custom tenant switch component to change the current URL.

    Please send an email to liming.ma@volosoft.com; I will share the source code of the Account layout with you.

    Page: /Themes/LeptonX/Layouts/Account/Default.cshtml

    https://abp.io/docs/latest/framework/ui/mvc-razor-pages/customization-user-interface

  • User Avatar
    0
    listtraderdev2 created

    Thank you for the response. I have sent the email as requested.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    I have shared the source code.

  • User Avatar
    0
    listtraderdev2 created

    Received. I will try it out and give you feedback.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    ok

  • User Avatar
    0
    listtraderdev2 created

    hi

    You can add a new component to switch the current tenant.

    If the new tenant name exists, Replace the current URL.

    1. https://tenant1.localhost:4200 try to link a new user that belongs to tenant2.
    2. User enters a new tenant2
    3. Checkthat tenant2 exists.
    4. Replace https://tenant1.localhost:4200 with https://tenant2.localhost:4200

    Thank you for the guide.

    For the custom switch component, per my understanding, I had to override these files; tenant-switch.js, TenantSwitchModal.cshtml and TenantSwitchModal.cshtml.cs. as found here https://github.com/abpframework/abp/tree/aec138a17fdfcb584f63ab69bd1e86064e53cd2d/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Pages/Abp/MultiTenancy

    In the Account layout of LeptonX theme I changed the highlighted block to this so I could still get the switch account option only when linking

    @if (!currentPageUrl.Contains("TenantRegister") && MultiTenancyOptions.Value.IsEnabled && (currentQueryString != null && currentQueryString.Contains("linkLogin"))) { <div> <div class="row"> <div class="col"> <span style="font-size: .8em;" class="text-uppercase text-muted">@MultiTenancyStringLocalizer["Tenant"]</span><br /> <h6 class="m-0 d-inline-block"> @if (CurrentTenant.Id == null) { <span> @MultiTenancyStringLocalizer["NotSelected"] </span> } else { <strong> @(CurrentTenant.Name ?? CurrentTenant.Id.Value.ToString()) </strong> } </h6> </div> <div class="col-auto"> <a id="AbpTenantSwitchLink" href="javascript:;" class="btn btn-sm btn-outline-primary">@MultiTenancyStringLocalizer["Switch"]</a> </div> </div> </div>

    but I am not sure what to do for this step

    1. Replace https://tenant1.localhost:4200 with https://tenant2.localhost:4200
  • User Avatar
    0
    listtraderdev2 created

    On the other hand I still have this issue :- The problem we are finding though is that if we attempt to impersonate a tenant from the host, we are not redirected to the tenant's URL (tenant1.domain.com) instead we stay at at the host URL with no subdomain (domain.com). as seen here - https://abp.io/support/questions/4615/Impersonate-tenant-issue-with-custom-tenant-resolver-by-sub-domain

    I feel I need to resolve this first to get the link account working. If that is the case can you guide me on this also? the solution to that problem is no longer available at the link you provided (https://github.com/balessi75/FM.Test/issues/1)

  • User Avatar
    0
    listtraderdev2 created

    hi

    You can add a new component to switch the current tenant.

    If the new tenant name exists, Replace the current URL.

    1. https://tenant1.localhost:4200 try to link a new user that belongs to tenant2.
    2. User enters a new tenant2
    3. Checkthat tenant2 exists.
    4. Replace https://tenant1.localhost:4200 with https://tenant2.localhost:4200

    Thank you for the guide.

    For the custom switch component, per my understanding, I had to override these files; tenant-switch.js, TenantSwitchModal.cshtml and TenantSwitchModal.cshtml.cs. as found here https://github.com/abpframework/abp/tree/aec138a17fdfcb584f63ab69bd1e86064e53cd2d/framework/src/Volo.Abp.AspNetCore.Mvc.UI.MultiTenancy/Pages/Abp/MultiTenancy

    In the Account layout of LeptonX theme I changed the highlighted block to this so I could still get the switch account option only when linking

    @if (!currentPageUrl.Contains("TenantRegister") && MultiTenancyOptions.Value.IsEnabled && (currentQueryString != null && currentQueryString.Contains("linkLogin"))) { <div> <div class="row"> <div class="col"> <span style="font-size: .8em;" class="text-uppercase text-muted">@MultiTenancyStringLocalizer["Tenant"]</span><br /> <h6 class="m-0 d-inline-block"> @if (CurrentTenant.Id == null) { <span> @MultiTenancyStringLocalizer["NotSelected"] </span> } else { <strong> @(CurrentTenant.Name ?? CurrentTenant.Id.Value.ToString()) </strong> } </h6> </div> <div class="col-auto"> <a id="AbpTenantSwitchLink" href="javascript:;" class="btn btn-sm btn-outline-primary">@MultiTenancyStringLocalizer["Switch"]</a> </div> </div> </div>

    but I am not sure what to do for this step

    1. Replace https://tenant1.localhost:4200 with https://tenant2.localhost:4200

    I have been able to get this part to work. I can now link accounts with custom tenant domains.

    The pending issue is that. when I go to the linked accounts list and I login with any of the accounts, I am successfully logged into the tenant but we are not redirected to the new tenant's URL instead we stay at the previous tenants URL. Similar issue as this. https://abp.io/support/questions/4615/Impersonate-tenant-issue-with-custom-tenant-resolver-by-sub-domain

    Please help me fix

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    There is a GetTenantDomain = (context, _) => Task.FromResult(context.Request.Scheme + "://" + context.Request.Host); in AbpAccountOptions to get tenant domain.

    The source code from https://abp.io/support/questions/4615/Impersonate-tenant-issue-with-custom-tenant-resolver-by-sub-domain

    I will try to use GetTenantDomain during Impersonate

    Thanks.

  • User Avatar
    0
    listtraderdev2 created

    Hello. Where do I find the IHostTenantRepository

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    You can inject other services to query tenant info.

    eg: ITenantStore

    https://github.com/abpframework/abp/blob/dev/framework/src/Volo.Abp.MultiTenancy.Abstractions/Volo/Abp/MultiTenancy/ITenantStore.cs#L9-L13

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

Made with ❤️ on ABP v9.1.0-preview. Updated on December 26, 2024, 06:07