Base solution for your next web application
Open Closed

Extend ABPSesion and its override its methods #3882


User avatar
0
omkarchoudhari created

Currently in the ABP Framwwork , while fetching any data , in case of a multitenant application, the currently logged-in user and the tenantId are checked by default. But for our application we want to be able to extend the ABPSession to also include another field called AccountId. So our session should check Logged-inUserId + TenantId + AccountId. Is it possible to override the existing methods (like GetAll() etc.)so that we can check the above OR it will manage automatically ?


2 Answer(s)
  • User Avatar
    0
    aaron created
    Support Team

    UserId is checked in AuthorizationHelper. You can implement IAuthorizationHelper:

    internal class AccountAuthorizationHelper : IAuthorizationHelper, ITransientDependency
    {
    }
    

    Replace the default AuthorizationHelper in your module:

    public override void PreInitialize()
    {
        Configuration.ReplaceService<IAuthorizationHelper, AccountAuthorizationHelper>();  
    }
    
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @omkarchoudhari,

    If you are using ASP.NET Core, you can define your custom session like this: <a class="postlink" href="https://gist.github.com/ismcagdas/6f2a9a3b5d7b907cb8d94a72124d59a1">https://gist.github.com/ismcagdas/6f2a9 ... 72124d59a1</a>

    Then you can use it to filter your entities in this example: #2428@570793a7-71cc-490f-8e5f-db9f0e2ef644

    Thanks.