Single Session Login in Laravel

后端 未结 6 1599
囚心锁ツ
囚心锁ツ 2020-12-03 05:35

I\'m trying to implement a user policy whereby only one user can login at a time. I\'m trying to build this on top of Laravel\'s Auth driver.

I\'ve thought of using

6条回答
  •  南方客
    南方客 (楼主)
    2020-12-03 05:50

    This question is much earlier, but someone will be benefited through these easy steps. No need to make extra migration or something else.

    The first step is to comment out the:

    \Illuminate\Session\Middleware\AuthenticateSession::class, line from App\Http Kernel.php class.

    Secondly add this line in your login function just after login attempt successfully and before redirection: \Auth::logoutOtherDevices(request('password'));

    Thanks.

提交回复
热议问题