2016-02-25 5 views
2

Я могу успешно войти в систему как пользователь, но он все равно получает auth в качестве гостя. Я не могу выйти или войти, потому что перенаправляет меня на домашнюю страницу. Я использую предварительно построенные в аутентификации для users.The только файл я изменился, что связан с этим вопросом является маршруты файлlaravel authentication always guest

Route::get('/', function() { 
// return view('welcome'); 
if (Auth::check()) { 
    return Auth::user(); 
} 
else 
{ 
    return 'guest'; 
} 
}); 

Route::group(['middleware' => ['web']], function() { 
// Authentication routes... 
Route::get('auth/login', 'Auth\[email protected]'); 
Route::post('auth/login', 'Auth\[email protected]'); 

// Registration routes... 
Route::get('auth/register', 'Auth\[email protected]'); 
Route::post('auth/register', 'Auth\[email protected]'); 
Route::get('auth/logout', 'Auth\[email protected]'); 

}); 
+1

Переместите свой маршрут «/» в веб-промежуточное программное обеспечение. – Alen

+0

Спасибо, что сработал. –

ответ

2

промежуточного веб начать сеанс так без сеанса не проведение проверки AUTH, поскольку авторизация используя сеанс.

Route::group(['middleware' => ['web']], function() { 

Route::get('/', function() { 
// return view('welcome'); 
if (Auth::check()) { 
    return Auth::user(); 
} 
else 
{ 
    return 'guest'; 
} 
}); 
// Authentication routes... 
Route::get('auth/login', 'Auth\[email protected]'); 
Route::post('auth/login', 'Auth\[email protected]'); 

// Registration routes... 
Route::get('auth/register', 'Auth\[email protected]'); 
Route::post('auth/register', 'Auth\[email protected]'); 
Route::get('auth/logout', 'Auth\[email protected]'); 

}); 
Смежные вопросы