2
我是laravel的新手,我安裝了auth scaffold,這裏是到目前爲止的路由。laravel 5.2如何保護只有經過認證的用戶的路由
Route::group(['middleware' => ['web']], function() {
Route::auth();
Route::get('/home', '[email protected]');
Route::get('addthreadhtml', function()
{
return View::make('addThreadForm');
});
Route::post('thread/add', '[email protected]');
Route::get('thread/showall', '[email protected]');
});
我要保護addthreadhtml非認證用戶訪問,如果用戶還沒有登錄,他們將被重定向到另一個視圖。
我該怎麼做?
你應該谷歌「訪問控制列表laravel」https://mattstauffer.co/blog/acl-access-control-list-authorization-in-laravel-5- 1 – Unex
https://laracasts.com/discuss/channels/laravel/protecting-admin-routes-laravel-42 –
使用'auth'中間件:https://laravel.com/docs/master/middleware#assigning-middleware -to-路線 –