Thanks. Let me rephrase the question: in your implementation - can multiple tenants have the same host? From the link you shared I think so, but confirmation would be nice. Thanks
Okay so I created two tenants. Tenant1 and Tenant2. Both have the same host "myapp.com". Each tenant has one user, user1 (tenant1) and user2 (tenant2).
When logging in I think this code is called:
private ApplicationTenant GetTenant()
{
var tenants = Context.Set<ApplicationTenant>().ToList();
var host = httpContextAccessor.HttpContext.Request.Host.Value;
return tenants.Where(t => t.Hosts.Split(',').Where(h => h.Contains(host)).Any()).FirstOrDefault();
}
So now when user2 wants to login, GetTenant() will always return tenant1 and user2 does not belong to tenant1 so logging in is not possible?
Tenants and Users are created when logged with tenantsadmin - it's up to you what values you will assign. If you have same host for different user/tenant combination indeed this code will return the first tenant.
tenant2user will not be able to login when navigating to localhost:5001 because tenant1 and tenant2 share the same host (localhost:5001) and therefore always tenant1 will be returned.
So just be sure, you are saying that in production it is a requirement that each tenant has own defined host (e.g. client1.myapp.com) and hosts cannot be shared accross tenants, correct?