Base solution for your next web application
Open Closed

Detect tenant by email/username (custom tenant resolver) #3935


User avatar
0
clusterkiller created

Hello,

we want a multi-client website with only one URL (portal. mysite. com). The tenant identification must work with the e-mail address. (unique).

We want to remove the tenant selection box on the login page (and other pages), and detect the tenant when login button is clicked

Maybe there are two great additional features (but not needed for us, maybe cool for others): Settings for allow on user-creation only unique e-mail Adresses or allow multiple same e-mail Adresses (for multi tenant-rights) and after the click on the login button there is a Modal Dialog with all possible tenants for this account.

I read something about "custom tenant resolver", but I don't find the place where you can implement something like that.

I would be very happy about a help/implementation.

Thank you. Regards Michael


5 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi Michael,

    We have suggested you a custom tenant resolver but after reading your post I think if you can find the user on login action with user's email address, tenantId will be automatically set to user's tenantId.

    If you disable MayHaveTenantFilter (see <a class="postlink" href="https://aspnetboilerplate.com/Pages/Documents/Data-Filters?searchKey=DisableFilter#DocDisableFilters">https://aspnetboilerplate.com/Pages/Doc ... bleFilters</a>) in AccountController's Login action (the one with HttpPost verb), your problem should be solved.

    But, if you are planning to use Db per tenant approach or if you are planning to store at least one tenant's data in a seperate database, this approach will not work. Please let us know if you want to use DB per tenant approach.

    Thanks.

  • User Avatar
    0
    clusterkiller created

    Hi, I´am using single database. The solution with the MayHaveTenantFilter works perfect. The best solution clean and simple!

    Thank you very much

    Regards Michael

  • User Avatar
    0
    ismcagdas created
    Support Team

    Great :)

  • User Avatar
    0
    cpadmin created

    How to do it in DB per Tenant approach?

  • User Avatar
    0
    ismcagdas created
    Support Team

    @cpadmin you can use AbpUserAccounts table to query all users of all tenants. In that way, you don't need to deal with other tenant databases before the login when detecting the tenant.