2017-01-17 140 views
1

我已經安裝了Lumen並嘗試實現身份驗證。流明5.3身份驗證

我正在使用Laravel Framework版本Lumen(5.3.3)(Laravel Components 5.3。*)。

在app.php中,我取消了以下注釋。

$app->withFacades(); 

$app->routeMiddleware([ 
    'auth' => App\Http\Middleware\Authenticate::class, 
]); 

$app->register(App\Providers\AuthServiceProvider::class); 

\app\Providers\AuthServiceProvider.php

public function boot() { 
     $this->app['auth']->viaRequest('api', function ($request) { 
      if ($request->input('api_token')) { 
       return User::where('api_token', $request->input('api_token'))->first(); 
      } 
     }); 
} 

在這裏,當我調試,是沒有得到執行viaRequest方法。

+0

你有沒有在你的roure中定義auth中間件? – dios231

回答

1

你有沒有定義您的路線如下:

$app->get('endpoint', ['middleware' => 'auth', function() { // }]); 

分配驗證中間件的路線。