Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Midedlware类在Laravel 5.3中不起作用_Php_Laravel_Redirect - Fatal编程技术网

Php Midedlware类在Laravel 5.3中不起作用

Php Midedlware类在Laravel 5.3中不起作用,php,laravel,redirect,Php,Laravel,Redirect,我有一个laravel应用程序在这个应用程序中,我有以下登录用户功能 public function login() { try { $inputs = Input::except('_token'); $validator = Validator::make($inputs, User::$login); if ($validator->fails()) { return Redirect::to(

我有一个laravel应用程序在这个应用程序中,我有以下登录用户功能

     public function login() {
    try {
        $inputs = Input::except('_token');
        $validator = Validator::make($inputs, User::$login);
        if ($validator->fails()) {
            return Redirect::to('/')->with('message', 'Please Enter Valid Credentials');
        } else {
            $respones = \UserHelper::processLogin($inputs);
            if ($respones) {

                return Redirect::to('/dashboard')->with('success_message', 'Welcome to Tressly Admin Dashboard');
            } else {
                return Redirect::to('/')->with('message', 'Please Enter Valid Information ');
            }
        }
    } catch (Exception $ex) {
        return CommonHelper::AdminExceptions($ex);
    }
}
现在,当用户注销并按下“上一步”按钮时,浏览器将显示缓存中的上一页。现在,在这个页面上,当用户试图访问任何受保护的路由应用程序时,它显示以下错误 我想将其重定向到“/”(主路由),因为在出现错误后,注销用户尝试访问任何保护路由

   Class App\Illuminate\Auth\Middleware\AdminAuthenticate does not exist
我做了一个自定义的认证中间件,中间件的处理功能是

      public function handle($request, Closure $next, $guard = null) {
    if (Auth::check()) {
        return $next($request);
    }
    return redirect('/');
}
我也在kernal.php中注册了$routeMiddleware,比如

   'authAdmin' => \Illuminate\Auth\Middleware\AdminAuthenticate::class,
保护我的路线

  Route::group(['middleware' => 'authAdmin'], function () {
      ///routes 
   });
有什么想法吗?

使用

    'authAdmin' => \App\Http\Middleware\AdminAuthenticate::class,
而不是

   'authAdmin' =>\Illuminate\Auth\Middleware\AdminAuthenticate::class,

我希望它能起作用

您为什么要创建一个定制的中间件类,该类的功能与现有的“auth”中间件完全相同

RedirectifAuthenticated.php执行此操作

public function handle($request, Closure $next, $guard = null)
{
    if (Auth::guard($guard)->check()) {
        return redirect('/home');
    }

    return $next($request);
}

类身份验证不起作用。我已经在AdminAuthenticate中使用了Auth,谢谢,它现在正在工作。你救了我一天。