Open Closed

Public website login tenant when subdomains are used #7012


0
p.j.keukens created

Hi,

In the admin site we are using the subdomain system to identify specific tenants.

Now we are setting up the public website but when they click the login button users can only login as host users, so tenant users are locked out. Is there any solution to this?

Best regards Patrick


8 Answer(s)
  • 0
    ryancyq created

    Hi, clicking on login button from the public website will not have any tenant information being known before hand.

    you can create a dropdown list of tenant names on either the public website or login page of the admin website.

  • 0
    p.j.keukens created

    Hi Ryan,

    I understand that I could do that, but you don't want the tenants to see all the other tenants, so a dropdown box is not an option.

  • 0
    p.j.keukens created

    Isn't it possible to determine the tenant based on the user logging in?

  • 0
    ryancyq created

    Hi, the user login has multi tenancy filter being applied, therefore, it only fetches users that belongs to tenant/host.

    You can modify the login to search for user from multiple tenants (by temporarily disable the data filter)

    also, by default, if tenant information cannot be resolved by the url, it should show a tenant name input on login page (unless it is disabled)

    see https://github.com/aspnetzero/aspnet-zero-core/blob/f606134b29efab6f137b6e8eba8f48293cddf894/angular/src/account/account.component.html#L13-L15

  • 0
    p.j.keukens created

    If I disable the mayhavetenant filter on login then the user can login, but clicking on a admin menu item sends the user back to the login page as the domain is the host domain and not the client domain. How could I redirect the user to the proper (tenant) subdomain after login?

    By the way I'm using the .net core & jquery version.

  • 0
    ismcagdas created

    @p.j.keukens

    • Can you use same approach (subdomain system to identify specific tenants) for the public website ?
    • Second apporach would be requesting user to enter tenancy name on the public website when they try to login. Then you can redirect to {TENANCY_NAME}.youradmsite.com.

    also, by default, if tenant information cannot be resolved by the url, it should show a tenant name input on login page (unless it is disabled)

    I think there will be no "change tenant" link because of supportsTenancyNameInUrl in https://github.com/aspnetzero/aspnet-zero-core/blob/dev/angular/src/account/account.component.ts#L57.

  • 0
    p.j.keukens created

    @ismcagdas Unfortunatly I cannot use the same subdomain approach for the public website, because it should be one public facing website and you are correct there is no "change tenant link" because we use the subdomain system.

    I would prefere that all users could login on the host url (or their subdomain if used) and then be redirected to the correct subdomain after the tenant is logged in.

    Is this possible and how would I do that?

  • 0
    ryancyq created

    Hi, you can add tenant subdomain in the return url upon login POST method.

    See https://github.com/aspnetzero/aspnet-zero-core/blob/f606134b29efab6f137b6e8eba8f48293cddf894/aspnet-core/src/MyCompanyName.AbpZeroTemplate.Web.Mvc/Controllers/AccountController.cs#L159-L163