Base solution for your next web application
Open Closed

how do you set the tenant for a user via url not subdomain? #9815


User avatar
0
slavaisayev created

version 9.2 .netcore angular

Hi,

I can see details in the docs about setting up tenants via sub domains but nothing about how we would set the tenant to default on the login screen by some other method or on the url.

A simple example is an admin add users to a tenant, they get the invite email and when they click unless we have tenant subdomains in place they are taken to the generic login screen and they have to know the name of their tenant etc.

What we really need is to be able to be able to do something like mysite.com/login?tenand=mycompany

Does this make sense? if there are any examples you can point me at it would be really helpful


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

    Hi slavaisayev, In theory, this is possible. You only need to inherit the ITenantResolveContributor interface and write your own parsing logic, just like the DomainTenantResolveContributor.

    e.g:

    public class UrlTenantResolveContributor : ITenantResolveContributor, ITransientDependency
    {
        public int? ResolveTenantId()
        {
            throw new NotImplementedException();
        }
    }
    
    public class YourModule : AbpModule
    {
        public override void PreInitialize()
        {
            Configuration.MultiTenancy.Resolvers.Insert(0,typeof(UrlTenantResolveContributor));
        }
    }
    
  • User Avatar
    0
    winstat created

    Hi, I have the same requirement and I understand the necessity to write a custom ITenantResolveContributor.

    But how to I fetch the current URL from within my contributor? Is there a service or a class I need to know about?

    Thanks