refactor: use DEMO_TENANT_PORT env var for demo logic isolation
This commit is contained in:
@@ -17,8 +17,9 @@ class LoginController extends Controller
|
||||
{
|
||||
$centralDomains = config('tenancy.central_domains', []);
|
||||
|
||||
// [Hack] Demo 環境特殊規則:Port 8081 強制視為租戶
|
||||
if (request()->getPort() != 8081 && in_array(request()->getHost(), $centralDomains)) {
|
||||
// [Hack] Demo 環境特殊規則
|
||||
$demoPort = config('tenancy.demo_tenant_port');
|
||||
if ((!$demoPort || request()->getPort() != $demoPort) && in_array(request()->getHost(), $centralDomains)) {
|
||||
return Inertia::render('Landlord/Auth/Login');
|
||||
}
|
||||
|
||||
@@ -45,8 +46,9 @@ class LoginController extends Controller
|
||||
|
||||
$centralDomains = config('tenancy.central_domains', []);
|
||||
$centralDomains = config('tenancy.central_domains', []);
|
||||
// [Hack] Demo 環境特殊規則:Port 8081 強制視為租戶
|
||||
if ($request->getPort() != 8081 && in_array($request->getHost(), $centralDomains)) {
|
||||
// [Hack] Demo 環境特殊規則
|
||||
$demoPort = config('tenancy.demo_tenant_port');
|
||||
if ((!$demoPort || $request->getPort() != $demoPort) && in_array($request->getHost(), $centralDomains)) {
|
||||
return redirect()->intended(route('landlord.dashboard'));
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,8 @@ class DashboardController extends Controller
|
||||
{
|
||||
$centralDomains = config('tenancy.central_domains', []);
|
||||
|
||||
if (request()->getPort() != 8081 && in_array(request()->getHost(), $centralDomains)) {
|
||||
$demoPort = config('tenancy.demo_tenant_port');
|
||||
if ((!$demoPort || request()->getPort() != $demoPort) && in_array(request()->getHost(), $centralDomains)) {
|
||||
return redirect()->route('landlord.dashboard');
|
||||
}
|
||||
|
||||
|
||||
@@ -20,9 +20,9 @@ class UniversalTenancy
|
||||
$centralDomains = config('tenancy.central_domains', []);
|
||||
|
||||
// [Hack] Demo 環境特殊規則:
|
||||
// 如果是 8081 端口,強制視為租戶請求 (忽略中央域名檢查)
|
||||
// 這樣可以讓 192.168.0.103:8081 直接訪問租戶,無需設定 hosts
|
||||
if ($request->getPort() == 8081) {
|
||||
// 如果設定了 demo_tenant_port (e.g. 8081),且請求端口相符,強制視為租戶請求
|
||||
$demoPort = config('tenancy.demo_tenant_port');
|
||||
if ($demoPort && $request->getPort() == $demoPort) {
|
||||
return app(InitializeTenancyByDomain::class)->handle($request, $next);
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,17 @@ return [
|
||||
array_map('trim', explode(',', env('CENTRAL_DOMAINS', '127.0.0.1,localhost')))
|
||||
),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Demo Mode Tenant Port
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| If set, requests on this port will be treated as tenant requests
|
||||
| regardless of the host domain. Useful for IP-based demo access.
|
||||
|
|
||||
*/
|
||||
'demo_tenant_port' => env('DEMO_TENANT_PORT'),
|
||||
|
||||
/**
|
||||
* Tenancy bootstrappers are executed when tenancy is initialized.
|
||||
* Their responsibility is making Laravel features tenant-aware.
|
||||
|
||||
Reference in New Issue
Block a user