1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-14 01:24:05 +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

@ -44,7 +44,12 @@ class InitializeTenancyByDomain extends IdentificationMiddleware
*/
public function requestHasTenant(Request $request): bool
{
return ! in_array($this->getDomain($request), config('tenancy.identification.central_domains'));
$domain = $this->getDomain($request);
// Mainly used with origin identification if the header isn't specified and e.g. universal routes are used
if (! $domain) return false;
return ! in_array($domain, config('tenancy.identification.central_domains'));
}
public function getDomain(Request $request): string