简体   繁体   English

localhost 将您重定向了太多次。 拉拉维尔

[英]localhost redirected you too many times. laravel

I checked with the guards, but they are set perfectly.我检查了警卫,但他们设置得很完美。 The problem I figured out is stated below.我想出的问题如下所述。 This is custom guard这是自定义守卫

Route::get('user/login', 'user\Authuser\userLoginController@showLoginForm')->name('user.login');  //this works fine 

Route::name('user.')->prefix('/user')->namespace('user')->group(function(){
   Route::namespace('Authuser')->group(function(){
    Route::get('/login','userLoginController@showLoginForm')->name('login');  //this give error, localhost redirected you too many times
    });
});

After you login , means that you are authenticated, then you should access the rest of your endpoints.登录后,意味着您已通过身份验证,然后您应该访问其余的端点。

Laravel has an easy implementation for that using Auth middleware. Laravel 有一个使用Auth中间件的简单实现。

Having said that your routes should look like:话虽如此,您的路线应该如下所示:

Route::get('user/login', 'user\Authuser\userLoginController@showLoginForm')->name('user.login'); 


Route::group(['middleware' => 'auth'], function () {
    Route::name('user.')->prefix('/user')->namespace('user')->group(function(){
        Route::namespace('Authuser')->group(function(){
            Route::get('/login','userLoginController@showLoginForm')->name('login');  //this give error, localhost redirected you too many times
        });
    });
});

Inside this group you can add all your application endpoints, that require authentication.在该组中,您可以添加所有需要身份验证的应用程序端点。

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

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