我有laravel路線的問題。我希望auth註冊路由只能由管理員或登錄用戶訪問。爲了實現這一點,我已經從routes.php文件刪除Route::auth();
並創建AUTH中間件我自己的路由表項。Laravel 5.2驗證中註冊用戶只有登錄用戶或管理員只
努力
Route::group(['middleware' => 'web'], function() {
// Authentication Routes...
$this->get('login', 'Auth\[email protected]');
$this->post('login', 'Auth\[email protected]');
$this->get('logout', 'Auth\[email protected]');
// Password Reset Routes...
$this->get('password/reset/{token?}', 'Auth\[email protected]');
$this->post('password/email', 'Auth\[email protected]');
$this->post('password/reset', 'Auth\[email protected]');
Route::get('/home', '[email protected]');
Route::post('/ajax/getStates', '[email protected]');
Route::post('/ajax/getCities', '[email protected]');
});
Route::group(['middleware' => ['web','auth']], function() {
// Registration Routes...
$this->get('register', 'Auth\[email protected]');
$this->post('register', 'Auth\[email protected]');
});
上面的代碼工作正常。當我試圖訪問註冊網址時,它只是將我重定向到登錄頁面。現在實際問題在登錄後開始。
登錄後,我試圖訪問註冊頁,但它並沒有顯示出來,而不是把它重定向我的家一樣http://localhost/
。
請給我解決方案。
它,因爲你已經確立了自己的''auth'中間件內註冊route',而不是你需要你的'web'中間件內得到它只有這樣你就可以在不登錄 –
訪問它,我想它應該是通過訪問記錄的用戶,而不是匿名用戶。這就是爲什麼我把它放在auth中間件中。 – Mandy
然後why're您在'AuthController' –