登录后错误的连接数太多

时间:2017-02-23 00:23:24

标签: laravel laravel-5 laravel-5.3 laravel-5.4

最近我在laravel 5.4上创建了一个应用程序,而且我通常会部署我的应用程序,唯一的区别是我用5.4版本创建了一个应用程序。 但是出了点问题,在我登录并重定向到管理仪表板后我得到了“连接错误的错误”的错误,我无法弄清楚我做错了什么?我一直都是完全正常的。

注意:这个错误只能在线进行,我的localhost机器工作正常。

这是我的routes.php

<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

//Route::get('/', 'PagesController@home');

Route::get('/', function () {
    return view('welcome');
});

Route::get('admin/', 'Auth\LoginController@showLoginForm');
Route::post('admin/', 'Auth\LoginController@login');

Route::post('admin/logout', 'Auth\LoginController@logout');


/************** ADMIN AREA ********************/
Route::group(['middleware' => ['auth', 'admin']], function() {

Route::get('admin/dashboard', 'PagesController@dashboard');

//Surveys
Route::get('admin/surveys/', 'SurveyController@index');
Route::get('admin/surveys/create', 'SurveyController@create');
Route::post('admin/surveys', 'SurveyController@store');
Route::get('admin/surveys/{id}/edit', 'SurveyController@edit');
Route::put('admin/surveys/{id}', 'SurveyController@update');
Route::delete('admin/surveys/{id}', 'SurveyController@destroy');

Route::get('admin/surveys/{id}/{email}/show', 'SurveyController@show');
Route::get('admin/surveys/{id}/results', 'SurveyController@results');

//Questions
Route::get('admin/questions/', 'QuestionController@index');
Route::get('admin/questions/create', 'QuestionController@create');
Route::post('admin/questions', 'QuestionController@store');
Route::get('admin/questions/{id}/edit', 'QuestionController@edit');
Route::put('admin/questions/{id}', 'QuestionController@update');
Route::delete('admin/questions/{id}', 'QuestionController@destroy');

//Answers
Route::post('admin/answers', 'AnswerController@store');
Route::get('admin/answers', 'AnswerController@index');

//Statistics
Route::get('admin/statistics','StatisticController@index');

//Questions Options
Route::get('admin/optionsquestions/', 'QuestionOptionController@index');
Route::get('admin/optionsquestions/create', 'QuestionOptionController@create');
Route::post('admin/optionsquestions', 'QuestionOptionController@store');
Route::get('admin/optionsquestions/{id}/edit', 'QuestionOptionController@edit');
Route::put('admin/optionsquestions/{id}', 'QuestionOptionController@update');
Route::delete('admin/optionsquestions/{id}', 'QuestionOptionController@destroy');

// Settings
Route::get('admin/settings', 'SettingController@edit');
Route::put('admin/settings/update', 'SettingController@update');




});


//Survey Online
Route::get('surveys/{id}/show', 'SurveyController@showPublic');

经过一些测试后,我注意到问题出现在我的管理中间件中,当我删除它时,它已经工作了,我离开了我的中间件,有人可以弄清楚它有什么问题吗?

public function handle($request, Closure $next)
    {
        if(auth()->check() && auth()->user()->account_type_id == 1){
            return $next($request);
        }

        return redirect('/admin');
    }

1 个答案:

答案 0 :(得分:0)

重定向错误太多意味着你已经使用中间件登录系统,中间件继续从一个路由重定向到另一个路由,因此浏览器会抛出太多的重定向错误。 您需要从任何一个路由中删除中间件,以便删除太多的重定向错误。