0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

laravel7 マルチ認証でログアウト後にログインできなくなる

Posted at

現象

管理者画面のログアウト後に違うアカウントでログインするとログインできないで「/login」にリダイレクトされる。

ちなみに認証は「laravel/ui 」を利用しています。

原因

ログアウト時にセッションがクリアされていないみたい。

対応

logout時にセッションをクリアするように修正。

--- a/app/Http/Controllers/Admin/Auth/LoginController.php
+++ b/app/Http/Controllers/Admin/Auth/LoginController.php
@@ -7,6 +7,7 @@ use App\Providers\RouteServiceProvider;
 use Illuminate\Foundation\Auth\AuthenticatesUsers;
 use Illuminate\Support\Facades\Request;
 use Illuminate\Support\Facades\Auth;
+use Illuminate\Support\Facades\Session;

 class LoginController extends Controller
 {
@@ -53,6 +54,7 @@ class LoginController extends Controller
     public function logout(Request $request)
     {
         Auth::guard('admin')->logout();
+        Session::flush();

         return $this->loggedOut($request);
     }

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?