Single Session Login in Laravel

后端 未结 6 1590
囚心锁ツ
囚心锁ツ 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 06:12

    With Laravel 5.6 and superior:

    in LoginController add method

    protected function authenticated()
    {
        \Auth::logoutOtherDevices(request('password'));
    }
    

    in Kernel

    remove comment from line

    \Illuminate\Session\Middleware\AuthenticateSession::class,
    

    That's it, the feature is now included in Laravel!

提交回复
热议问题