【问题标题】:Laravel 5.1 logout redirect not workingLaravel 5.1注销重定向不起作用
【发布时间】:2016-08-23 14:42:49
【问题描述】:

当我在我的应用程序中单击注销时,我会被重定向到 Laravel 5 默认页面。我试图将 url 切换到登录名,但我仍然被重定向到这个默认页面,而不是错误。 这是我的 AuthController 中的代码

public function doLogout()
{
    Auth::logout();
    Session::flush();
     return Redirect::to('login');

也是我的 routes.php 中的注销

Route::get('auth/logout', 'Auth\AuthController@getLogout');

关于如何重定向到登录页面的任何想法。谢谢

【问题讨论】:

  • 您的路由似乎没有使用 doLogout 方法。

标签: php laravel model-view-controller


【解决方案1】:

你可以使用下面的类

protected $redirectAfterLogout = 'auth/login';

"auth/login" 是你可以更改的 url,这是 laravel 5 的

文档:

https://laravel.com/docs/5.1/authentication

【讨论】:

    猜你喜欢
    • 2023-04-08
    • 2017-02-20
    • 2023-03-10
    • 2016-10-28
    • 2013-09-15
    • 2016-03-11
    • 1970-01-01
    • 1970-01-01
    • 2016-02-13
    相关资源
    最近更新 更多