Open Closed

how to use ClaimsIdentity with current Tenant #6961


User avatar
0
ElifKaya created

Hi,

I need to use ClaimsPrincipal with current tenant. Actually, there is no problem without tenant. I also used _currentTenant.Change but, it throws Volo.Abp.Authorization.AbpAuthorizationException when I call to PhaseAppservice as below. I need to access to appService in IDistributedEventHandler also.

Check the docs before asking a question: https://docs.abp.io/en/commercial/latest/ Check the samples to see the basic tasks: https://docs.abp.io/en/commercial/latest/samples/index The exact solution to your question may have been answered before, and please first use the search on the homepage. Provide us with the following info:

  • ABP Framework version: v7.3.1
  • UI Type: Angular / MVC
  • Database System: EF Core (SQL Server)
  • Tiered (for MVC) or Auth Server Separated (for Angular): yes/
  • Exception message and full stack trace:
  • Steps to reproduce the issue:

3 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    Can you share the full error logs?

  • User Avatar
    0
    ElifKaya created

    Hi,

    Can you share the full error logs?

    Hi,

    Actually, current user has permission and it didn't throw exception from other appService with this tenant. It throwed exception when we use tenant just EventHandler.cs. So I think that we need to add tenant information in ClaimsPrincipal, is it possible or can you advice any other option? Thanks

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    You can try

    claimsIdentity.AddClaim(new Claim(AbpClaimTypes.TenantId, eventData.TenantId.ToString()))
    
Made with ❤️ on ABP v9.1.0-preview. Updated on December 12, 2024, 07:15