我正在尝试验证laravel 5.2中的用户类型。这条路线是如下:Laravel auth不显示会话消息
Route::group(['middleware' => ['web']], function(){
Route::auth();
Route::get('/user/department/login', ['as' => 'department_login', 'uses' => 'DepartmentUserAuth\[email protected]']);
Route::post('/user/department/login','DepartmentUserAuth\[email protected]');
});
而且AuthController.php
是
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');
}
}
而且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()) }}
但Session::has('message')
是空的,而dump
如下所示:
array:3 [▼
"_token" => "BvQ630KrUl78Ngb8d3cst6pAIqenra3ohbYbLzAP"
"_previous" => array:1 [▼
"url" => "http://localhost:8080/material/public/user/department/login"
]
"flash" => array:2 [▼
"old" => []
"new" => []
]
]
如何在我的login.blade.php
中显示所有错误消息(如默认身份验证控制器中的错误消息)?
粘贴' config/auth.php'代码 –
你可以添加这样的消息。 '$ request-> request-> add(['message'=>“Your custome Message”]);'不加入会话。使用Input() –