1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-13 12:44:04 +00:00

Fix origin id w/ empty header & using full-hostname subdomain records

This makes it possible to have Domain records in both `foo` and
`foo.{centralDomain}` format when using the combined domain/subdomain
identification middleware, or the origin header id mw which extends it.

This commit also refactors some related logic.
This commit is contained in:
Samuel Štancl 2024-11-09 20:48:45 +01:00
parent c199a6e0c8
commit 56dd4117ab
7 changed files with 131 additions and 63 deletions

View file

@ -12,6 +12,7 @@ use Stancl\Tenancy\Contracts\SingleDomainTenant;
use Stancl\Tenancy\Contracts\Tenant;
use Stancl\Tenancy\Exceptions\TenantCouldNotBeIdentifiedOnDomainException;
use Stancl\Tenancy\Tenancy;
use Illuminate\Support\Str;
class DomainTenantResolver extends Contracts\CachedTenantResolver
{
@ -55,6 +56,11 @@ class DomainTenantResolver extends Contracts\CachedTenantResolver
return $tenant;
}
public static function isSubdomain(string $domain): bool
{
return Str::endsWith($domain, config('tenancy.identification.central_domains'));
}
public function resolved(Tenant $tenant, mixed ...$args): void
{
$this->setCurrentDomain($tenant, $args[0]);