From 1ee57f3e880898074387ade08f75e14be0163e51 Mon Sep 17 00:00:00 2001 From: sky121113 Date: Tue, 19 May 2026 16:51:43 +0800 Subject: [PATCH] =?UTF-8?q?feat(auth):=20=E5=AF=A6=E4=BD=9C=E5=BE=8C?= =?UTF-8?q?=E5=8F=B0=E5=96=AE=E4=B8=80=E8=A8=AD=E5=82=99=E7=99=BB=E5=85=A5?= =?UTF-8?q?=EF=BC=8C=E4=B8=A6=E5=A5=97=E7=94=A8=20auth.session=20=E4=B8=AD?= =?UTF-8?q?=E9=96=93=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Auth/AuthenticatedSessionController.php | 3 +++ routes/web.php | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/Auth/AuthenticatedSessionController.php b/app/Http/Controllers/Auth/AuthenticatedSessionController.php index 494a106..a82ff9e 100644 --- a/app/Http/Controllers/Auth/AuthenticatedSessionController.php +++ b/app/Http/Controllers/Auth/AuthenticatedSessionController.php @@ -27,6 +27,9 @@ class AuthenticatedSessionController extends Controller { $request->authenticate(); + // 剔除該帳號在其他設備上的所有 Session 連線 + Auth::logoutOtherDevices($request->password); + $request->session()->regenerate(); return redirect()->intended(RouteServiceProvider::HOME); diff --git a/routes/web.php b/routes/web.php index d844b06..a2cc55a 100644 --- a/routes/web.php +++ b/routes/web.php @@ -30,9 +30,9 @@ Route::get('/t/{slug}', [App\Http\Controllers\Guest\PassCodeController::class, ' Route::get('/dashboard', function () { return redirect()->route('admin.dashboard'); -})->middleware(['auth', 'verified'])->name('dashboard'); +})->middleware(['auth', 'auth.session', 'verified'])->name('dashboard'); -Route::middleware(['auth', 'verified', 'tenant.access'])->prefix('admin')->name('admin.')->group(function () { +Route::middleware(['auth', 'auth.session', 'verified', 'tenant.access'])->prefix('admin')->name('admin.')->group(function () { // 1. 儀表板 Route::get('/dashboard', [App\Http\Controllers\Admin\DashboardController::class, 'index'])->name('dashboard');