fix(middleware): create missing PreventAccessFromTenantDomains middleware
This commit is contained in:
20
app/Http/Middleware/PreventAccessFromTenantDomains.php
Normal file
20
app/Http/Middleware/PreventAccessFromTenantDomains.php
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Middleware;
|
||||||
|
|
||||||
|
use Closure;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Stancl\Tenancy\Tenancy;
|
||||||
|
|
||||||
|
class PreventAccessFromTenantDomains
|
||||||
|
{
|
||||||
|
public function handle(Request $request, Closure $next)
|
||||||
|
{
|
||||||
|
// 如果租戶已初始化 (代表是從租戶域名存取),則禁止訪問 Landlord 路由
|
||||||
|
if (tenancy()->initialized) {
|
||||||
|
abort(404);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $next($request);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -14,7 +14,7 @@ use App\Http\Controllers\Landlord\TenantController;
|
|||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Route::prefix('landlord')->name('landlord.')->middleware(['web', 'auth', \Stancl\Tenancy\Middleware\PreventAccessFromTenantDomains::class])->group(function () {
|
Route::prefix('landlord')->name('landlord.')->middleware(['web', 'auth', \App\Http\Middleware\PreventAccessFromTenantDomains::class])->group(function () {
|
||||||
// 房東儀表板
|
// 房東儀表板
|
||||||
Route::get('/', [DashboardController::class, 'index'])->name('dashboard');
|
Route::get('/', [DashboardController::class, 'index'])->name('dashboard');
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user