[英]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.