繁体   English   中英

Laravel 5.3身份验证路由重定向到/

[英]Laravel 5.3 auth routes redirecting to /

我刚刚从5.2升级到Laravel 5.3(现在),而auth路由存在问题。

我实现了RegisterController所需的方法,并添加了Auth::routes(); routes/web.php 但是当我访问/ register时,我总是被重定向到/

我不知道为什么,也不知道如何找出问题所在。

中间件:

protected $middlewareGroups = [
        'web' => [
            \App\Http\Middleware\EncryptCookies::class,
            \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
            \Illuminate\Session\Middleware\StartSession::class,
            \Illuminate\View\Middleware\ShareErrorsFromSession::class,
            \Illuminate\Routing\Middleware\SubstituteBindings::class,
            \App\Http\Middleware\VerifyCsrfToken::class,
        ],
        'api' => [
            'throttle:60,1',
            'bindings',
        ],
    ];

更新:我发现了原因:我已经登录了,因此它总是转发给我。 我仍然不知道,是在做吗?

刚刚找到原因。

RedirectIfAuthenticated中间件中:

if (Auth::guard($guard)->check()) {
     return redirect('/');
}

Auth :: routes()只是一个帮助程序类,可帮助您生成用户身份验证所需的所有路由。 要更改代码,您可以浏览以下链接:

// Authentication Routes...
$this->get('login', 'Auth\LoginController@showLoginForm')->name('login');
$this->post('login', 'Auth\LoginController@login');
$this->post('logout', 'Auth\LoginController@logout')->name('logout');

// Registration Routes...
$this->get('register', 'Auth\RegisterController@showRegistrationForm')->name('register');
$this->post('register', 'Auth\RegisterController@register');

// Password Reset Routes...
$this->get('password/reset', 'Auth\ForgotPasswordController@showLinkRequestForm');
$this->post('password/email', 'Auth\ForgotPasswordController@sendResetLinkEmail');
$this->get('password/reset/{token}', 'Auth\ResetPasswordController@showResetForm');
$this->post('password/reset', 'Auth\ResetPasswordController@reset');

您可能必须检查此功能$this->get('register', 'Auth\\RegisterController@showRegistrationForm')->name('register'); 更改路径,或者它与您的中间件有关。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM