Auth::user() returns null

后端 未结 6 1482
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-03 04:47

I use Laravel 5.2 and have a problem with middleware. There is the code in the routes.php


    use Illuminate\\Contracts\\Auth\\Access\\Gate;


    Route::group([         


        
6条回答
  •  自闭症患者
    2020-12-03 04:59

    Define middle in the constructer of your controller and it will do the trick here

    public function __construct()
    {
        $this->middleware('auth:api');
    }
    

提交回复
热议问题