[英]Laravel Route protection for authenticated users
我有幾個類似於下面的鏈接,我希望通過這樣的條件來保護它們:只有登錄的用戶才能訪問指定的視圖。
這是我要保護的路線樣本:
Route::get('home', array('as' => 'home', 'uses' => 'MembersController@loadHome'));
我想檢查用戶是否通過了身份驗證
'before' => 'auth'
如何修改上述路由以包含before => auth?
提前致謝。
Route::get('home', array('before' => 'auth', 'as' => 'home', 'uses' => 'MembersController@loadHome'));
這樣,或者您可以像這樣保護一組路線;
Route::group(array('before' => 'auth'), function(){
Route::get('home', array('as' => 'home', 'uses' => 'MembersController@loadHome'));
Route::get('another', array('as' => 'another', 'uses' => 'Controller@method'));
.....
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.