我有三个角色Hr,staff和admin ...我使用3个中间件防护来保护每个角色....但是不知道为什么职员(默认Web防护)不允许我登录...给出未定义的索引密码错误。
//控制器功能
public function logged(Request $request)
{
$this->validate($request,[
'email' => 'required|email',
'password' => 'required|min:6'
]);
if (Auth::guard('web')->attempt(['email'=>$request->email,
'password' => $request->password]))
{
return redirect()->intended(url('/home'));
}
Session::flash('message','Invalid Login details');
return redirect()->back()->withInput($request->only('email','remember'));
}
//我的观点
<div class="m-t-40 card-box">
<div class="panel-body">
<div class="login-form">
<h4><center>Login</center></h4>
<form action="{{route('login.submit')}}" method="POST" data-parsley-validate >
<input type="hidden" name="_token" value="{{csrf_token()}}"/>
<input type="text" name="email" placeholder="Email address" value="{{old('email')}}" required>
<input type="password" name="password" class="pass" placeholder="Password" required>
<span class="check-left"><input type="checkbox" name="remember" {{ old('remember') ? 'checked' : '' }}> Remember Me</span>
<span class="check-right"><a href="{{url('/reset')}}">Forgot password?</a></span>
<div class="clearfix"></div>
<button class="btn btn-info btn-block" type="submit">Sign in</button>
<p class="center-block mg-t mg-b">Dont have and account?
<a href="{{url('/signup')}}"> Register here.</a>
</p>
</form>
</div>
</div>
</div
// config / auth
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'api' => [
'driver' => 'token',
'provider' => 'users',
],
'admin'=> [
'driver' => 'session',
'provider' => 'admins',
],
'admin-api' => [
'driver' => 'token',
'provider' => 'admins',
],
'hr' => [
'driver' => 'session',
'provider' => 'hrs',
],
'hr-api' =>[
'driver' => 'token',
'provider' => 'hrs'
],
],
//错误的屏幕截图