419在Laravel中使用中间件后页面已过期

时间:2020-01-02 11:22:16

标签: laravel laravel-6

在我获得419页之后,我向我的项目添加了一个简单的中间件!我用laravel 6

路由页面:

Route::post('cours','AdminController@coursSubmit')->middleware('chekname');

查看页面:

<form action="edusubmit" method="post" enctype="multipart/form-data">
                                @csrf
                                <input name="title" type="text" placeholder="title">
                                <br><hr>
                                <input name="publisher" type="text"value="{{ Auth::user()->name }}" readonly>
                                <br><hr>
                                <textarea name="description" placeholder="در این قسمت متن مقاله ی خود را وارد کنید"></textarea>
                                <br><hr>
                                <label>عکس مقاله را بارگزاری کنید</label>
                                <br>
                                <input name="image" type="file">
                                <br><hr>
                                <input name="submit" type="submit">
                                <br><hr>
                            </form>

中间件:

   public function handle($request, Closure $next)
    {
        if ($request->title == 'masoud')
        return $next($request);
        return view('/');
    }
}

内核:

'chekname' => chekName::class,

1 个答案:

答案 0 :(得分:0)

修改内核

 'chekname' => \App\Http\Middleware\chekName::class,   

修改中间件


  public function handle($request, Closure $next)
    {
        if ($request->title != 'masoud'){
             return redirect('/');
          }
        return $next($request);
    } 
}

在中间件中,您应返回$next($request);