1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-02-04 05:34:04 +00:00

Fix DomainTenantResolver::isSubdomain()

Previously, the method returned `true` even for central domains, or tenant domains that ended with a central domain (e.g. tenant-app.test when app.test was central domain).
This fix is basically the same as in #1423.
This commit is contained in:
lukinovec 2025-12-29 14:14:59 +01:00
parent cde48a9b35
commit 4287f2a8a0

View file

@ -13,6 +13,7 @@ use Stancl\Tenancy\Contracts\SingleDomainTenant;
use Stancl\Tenancy\Contracts\Tenant;
use Stancl\Tenancy\Exceptions\TenantCouldNotBeIdentifiedOnDomainException;
use Stancl\Tenancy\Tenancy;
use Illuminate\Support\Arr;
class DomainTenantResolver extends Contracts\CachedTenantResolver
{
@ -58,7 +59,19 @@ class DomainTenantResolver extends Contracts\CachedTenantResolver
public static function isSubdomain(string $domain): bool
{
return Str::endsWith($domain, config('tenancy.identification.central_domains'));
$centralDomains = Arr::wrap(config('tenancy.identification.central_domains'));
foreach ($centralDomains as $centralDomain) {
if ($domain === $centralDomain) {
return false;
}
if (Str::endsWith($domain, '.' . $centralDomain)) {
return true;
}
}
return false;
}
public function resolved(Tenant $tenant, mixed ...$args): void