Php Laravel:如何防止使用同一用户帐户多次登录?
如何防止在任何类型的浏览器中使用相同的用户凭据多次登录?谢谢您…您可以使用Php Laravel:如何防止使用同一用户帐户多次登录?,php,laravel,Php,Laravel,如何防止在任何类型的浏览器中使用相同的用户凭据多次登录?谢谢您…您可以使用auth()->登录其他设备($request->password)功能 参考链接 它将注销具有相同用户的所有其他用户 LoginController.php中的 添加此代码 use Illuminate\Support\Facades\Auth; /** * Send the response after the user was authenticated. * * @param
auth()->登录其他设备($request->password)代码>功能
参考链接
它将注销具有相同用户的所有其他用户
LoginController.php中的
添加此代码
use Illuminate\Support\Facades\Auth;
/**
* Send the response after the user was authenticated.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
protected function sendLoginResponse(Request $request)
{
$request->session()->regenerate();
$this->clearLoginAttempts($request);
if ($response = $this->authenticated($request, $this->guard()->user())) {
return $response;
}
auth()->logoutOtherDevices($request->password);
return $request->wantsJson()
? new Response('', 204)
: redirect()->intended($this->redirectPath());
}
在上述代码中,覆盖laravel内部使用的相同代码
仅auth()->登录其他设备($request->password)代码>是在您需要此功能时添加的
您需要在app/Http/Kernel.php类的web中间件组中取消注释:
'web'=>[
// ...
\Illumb\Session\Middleware\AuthenticateSession::class,
// ...
],
谢谢……非常感谢。。。maraming salamat po,,,在哪里可以添加此功能?非常感谢。它的魅力。。。