$credentials = [
'email' => Input::get('email'),
'password' => Input::get('password'),
'active' => 1, //active
];
//Message if user in active user trying to logged in "This user is inactive mode conact to admin"
if (Auth::attempt($credentials, true)) {
//logged in
}else{
//Error
}
如果活跃用户中的用户尝试登录“此用户处于非活动状态,则会发送给管理员”,则应返回消息 我们如何检查Auth :: attempts异常错误,请建议。
提前致谢
答案 0 :(得分:3)
请像这样编码 首先检查凭据是否正确,然后检查活动状态
$credentials = [
'email' => Input::get('email'),
'password' => Input::get('password')
];
if (Auth::attempt($credentials)) {
$user = Auth::user();
if($user->active == 1) {
// Login successfully
} else {
return error for inactive
}
}else{
//Error
}
答案 1 :(得分:0)
$credentials = [
'email' => Input::get('email'),
'password' => Input::get('password'),
'active' => 1, //active
];
//如果活跃用户中的用户尝试登录"该用户是 非活动模式与管理员合作#34;
if (Auth::attempt($credentials)) {
if(Auth::user()->active == 1) {
// Login successfully
} else {
return back()->with('error','your account is inactive');
}
}else{
return back()->with('error','user is inactive');
}
现在在您的视图页面
@if(Session::has('error'))
{{Session::get('error')}}
@endif