如果我理解正确的话,用户必须验证其自身然后你想检查角色。不需要具有特定的角色。在文件的顶部
/**
* The user has been authenticated.
*
* @param \Illuminate\Http\Request $request
* @param mixed $user
* @return mixed
*/
protected function authenticated(Request $request, $user)
{
if(empty($user->role)) {
$this->guard()->logout();
return back()->withErrors(['There is no role specified']);
}
}
如果你希望用户;(你必须写使用照亮\ HTTP \请求:如果是这样,你可以在你的LoginController这样覆盖认证()方法。有特定的角色,你可以重写LoginController中的credentials()方法:
protected function credentials(Request $request)
{
$credentials = $request->only($this->username(), 'password');
$credentials['role'] = 'requiredRole';
return $credentials;
}
非常感谢这是我正在寻找的! – fefe