2016-02-18 88 views
-2

我創建一個Laravel 5.2應用程序有以下途徑:防止未經授權的航線

api/vehicle 
api/note 
api/task 

我使用AngularJS,我想阻止URL http://localhost:8000/api/note的未經授權的訪問(只有合法的用戶才能看到響應) 。

+0

歡迎計算器。你能否試着重新解釋你的問題,因爲它不清楚你想要什麼幫助。請查看並遵循[這些](http://stackoverflow.com/help/how-to-ask)準則。 –

+0

到目前爲止你有什麼?這是由服務器端處理.. 401 *錯誤..未經授權..您的客戶端只需要對它作出反應.. – Pogrindis

回答

1

您可以在路由器或控制器中使用auth中間件。

class ApiController extends Controller { 
    public function __construct() { 
     $this->middleware('auth'); 
    } 
} 

OR

Route::group([middleware => 'auth', 'prefix' => 'api'], function(){ 
    // your routes here 
});