Open Closed

Is it possible to change the tenant after login? #820


User avatar
0
shobhit created

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, please use the search on the homepage.

  • ABP Framework version: v4.0.2
  • UI type: Angular
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Seperated (Angular): Identity Server Seperated
  • Exception message and stack trace: -
  • Steps to reproduce the issue:

Used separate identityserver4 and angular version. My question is it possible to change the tenant after login? In one application have multiple tenants. There is two or more users. All of them have same username, mail address, other infos, but have different tenantId. Is it possible to change the tenant after login? if the abp not support yet, please let me know how can i do it, give me some guides


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

    Hi,

    ABP allows you to switch current tenants within the scope: https://docs.abp.io/en/abp/latest/Multi-Tenancy#change-the-current-tenant.

  • User Avatar
    0
    shobhit created

    yes, I know, it is temporary. I want to permanent in all scope. Also the angular side and current auth cookie/token must change

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    Unfortunately, it is currently not possible. The tenant must be determined before logging in.

  • User Avatar
    0
    shobhit created

    Okey, currently it is not possible. My question is how can i develop it? Where and how should I extend

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    May be you can get the new token on the server side and replace the token in the browser local storage.

  • User Avatar
    0
    shobhit created

    Sorry but your support is so basic.

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    This is a big question, it takes a lot of effort to do this.

    Here are some of my suggestions(just an idea):

    1. JWT cannot be changed, it is designed to be immutable.
    2. When you change the tenant, the current user must also change
    3. You can provide a Http API and use code to get Token.
    4. Replace token in local storage in angular code.
    5. Refresh the page to get the application configuration
  • User Avatar
    0
    shobhit created

    okey thanks. I will try then i will write the result

  • User Avatar
    0
    alper created
    Support Team Director

    @shobhit, you might be going on the wrong direction. there shouldn't be requirement to change tenant like that. You can redesign it with a different solution. because it breaks major framework rules.

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