I am trying to authenticate a user type in laravel 5.2. The route is as follows:
Route::group(['middleware' => ['web']], function(){
Route::auth();
Route::get('/user/department/login', ['as' => 'department_login', 'uses' => 'DepartmentUserAuth\AuthController@showLoginForm']);
Route::post('/user/department/login','DepartmentUserAuth\AuthController@deptLoginPost');
});
And AuthController.php
there is
public function deptLoginPost(Request $request)
{
$this->validate($request, [
'username' => 'required',
'password' => 'required',
]);
if (auth()->guard('department_user')->attempt(['username' => $request->input('username'), 'password' => $request->input('password')]))
{
$user = auth()->guard('department_user')->user();
dd($user);
}else{
return redirect('/user/department/login')->with('message', 'Invalid credentials');
}
}
And login.blade.php
:
@if(Session::has('message'))
<div class="row">
<div class="col-lg-12">
<div class="alert {{ Session::get('alert-class', 'alert-info') }}">
<button type="button" class="close" data-dismiss="alert">×</button>
{!! Session::get('message') !!}
</div>
</div>
</div>
@endif
{{ dump(session()->all()) }}
But Session::has('message')
empty, and dump
shown below:
array:3 [▼
"_token" => "BvQ630KrUl78Ngb8d3cst6pAIqenra3ohbYbLzAP"
"_previous" => array:1 [▼
"url" => "http://localhost:8080/material/public/user/department/login"
]
"flash" => array:2 [▼
"old" => []
"new" => []
]
]
How can I display all error messages (as in auth controller by default) in mine login.blade.php
?
source
share