Multi tenancy sub-domain redirection problem
Hello,
I have multiple tenants attached to a user and I am using wildcard subdomains for each tenant url.
Everything works good but the issue with redirection after logging in has a little problem which I think should be an easy fix but I am struggling to figure it out.
Here are the details:
User is attached to 2 tenants with slugs company-1 and company-2
subdomain is company-1.domain.com and company-2.domain.com
I have setup default tenant and latest tenant in User model.
so the issue is when a user tries to login using company-2.domain.com they get redirected to company-1.domain.com/dashboard where user has to switch to company 2 to access it.
I need a solution to redirect user to the same subdomain which they used to login.
Thank you so much in advance.
I have multiple tenants attached to a user and I am using wildcard subdomains for each tenant url.
Everything works good but the issue with redirection after logging in has a little problem which I think should be an easy fix but I am struggling to figure it out.
Here are the details:
User is attached to 2 tenants with slugs company-1 and company-2
subdomain is company-1.domain.com and company-2.domain.com
I have setup default tenant and latest tenant in User model.
so the issue is when a user tries to login using company-2.domain.com they get redirected to company-1.domain.com/dashboard where user has to switch to company 2 to access it.
I need a solution to redirect user to the same subdomain which they used to login.
Thank you so much in advance.
Solution
@Steve_OH I got it working with this middleware code. My Team model is Company and tenant login url is dashboard/login
VerifyNotAdmin.php1.56KB