Log*_*uck 3 php mysql authentication session laravel
我最近设置会话以保存到数据库并在sessions表中添加了user_id字段,以便我可以显示登录用户的名称.为了让laravel在用户登录时保存用户的id(给定laravel不定期查找user_id列),我不得不在Authenticate.php文件中添加一些代码来处理它.
现在,我正在尝试将user_id字段设置为null当用户注销时,因为目前,因为user_id字段即使在他们注销后仍然包含用户的id,所以即使他们不再登录,它仍然会在登录时显示它们.我希望扩展auth/logout功能,而不实际触及供应商文件,以包括我的功能,以便在注销时将user_id设置为null.
我可以在哪里添加此功能?在AuthController.php文件中?在routes.php中添加我自己的auth/logout路由声明?
如果您对我有任何疑问或需要我更好地解释一下,请告诉我.
谢谢.
您可以使用以下函数AuthController.php来覆盖AuthenticatesAndRegistersUsers特征的默认函数.你可以根据需要改变它.
/**
* Log the user out of the application.
*
* @return \Illuminate\Http\Response
*/
public function getLogout()
{
$this->auth->logout();
return redirect(property_exists($this, 'redirectAfterLogout') ? $this->redirectAfterLogout : '/');
}
Run Code Online (Sandbox Code Playgroud)