I am trying to authenticate a user against an API in Laravel 5.3. This does not work. Auth is not saved after redirecting a user after logging in.
Routes are configured as follows:
Route::group(['middleware' => 'web'], function () {
Route::group(['middleware' => 'auth'], function () {
Route::get('/', 'Users\DashboardController@index');
});
Route::get('login', 'Auth\LoginController@getLogin');
Route::post('login', 'Auth\LoginController@postLogin');
Route::get('logout', 'Auth\LoginController@getLogout');
});
In LoginController.php I use
protected $redirectTo = '/';
public function getLogin()
{
return view('auth.login');
}
public function postLogin(Request $request)
{
$this->login($request);
}
After logging in to a system that was successfully saved to a file, the session does not start for the route '/'.
So the route 'login':
dd($session); in Illuminate \ Auth \ SessionGuard returns #started : true
Store {#153 ▼
#id: "fo9Q8WuBio5BBus70WmzFPZmkXkjsYQlYEHsVHI4"
#name: "laravel_session"
#attributes: array:4 [▼]
#bags: []
#metaBag: MetadataBag {
#bagData: array:1 [▼]
#handler: FileSessionHandler {
#started: true
}
but #startedis false when the route is in 'auth'the middleware group ( '/'in my case).
I checked some, and #startedalso incorrectly, when I placed the route '/'outside the middleware group 'auth', but called Auth::check()in the controller.
, , 5.2 (Auth, Laravel 5.2
), .
, , '/' .
!