mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-04 09:04:03 +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:
parent
cde48a9b35
commit
4287f2a8a0
1 changed files with 14 additions and 1 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue