简体   繁体   English

验证后的Laravel 5.1重定向

[英]Laravel 5.1 redirect after auth

I am using laravel 5.1 and have a route similar to: 我正在使用laravel 5.1,并且路由类似于:

Route::get('/{id}/write-review', ['middleware' => 'auth', 'uses' => 'ItemController@writeReview']);

The problem I have is that when someone goes to this page (when not logged in) they get redirected to login, which is fine, but then redirected to the $redirectPath set in AuthController.php . 我遇到的问题是,当有人转到此页面时(未登录时),他们将被重定向到登录名,这很好,但随后将其$redirectPathAuthController.php中设置的$redirectPath I would like them to be redirected back to the review page. 我希望将他们重定向回评论页面。

Thanks in advance. 提前致谢。

The intended redirect function will redirect the user to the URL they were attempting to access before being caught by the authentication filter. 预期的重定向功能会将用户重定向到他们尝试访问的URL,然后再被身份验证过滤器捕获。 A fallback URI may be given to this method in case the intended destination is not available. 在预期的目标不可用的情况下,可以为此方法提供后备URI。 https://laravel.com/docs/5.1/authentication#authenticating-users https://laravel.com/docs/5.1/authentication#authenticating-users

 return redirect()->intended('dashboard');

I think i found the problem route {id}/write-review must be under the web middleware 我认为我发现问题路由{id} / write-review必须在Web中间件下

  Route::group(['middleware' => ['web']], function () {
    Route::get('login', 'Auth\AuthController@getLogin');
    Route::post('login', 'Auth\AuthController@postLogin');
    Route::get('logout', 'Auth\AuthController@getLogout');

    Route::group(['middleware' => ['auth']], function () {
        Route::get('/{id}/write-review', ['uses' => 'ItemController@writeReview']);
    });
});

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

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