@Ci A better way and easier way is to pass the desired state to your attempt method
This is the default postLogin from the AuthController from L5
public function postLogin (Request $request)
{
$this->validate($request, [
'email' => 'required', 'password' => 'required',
]);
$credentials = $request->only('email', 'password');
$credentials['active'] = 1;
if ($this->auth->attempt($credentials, $request->has('remember'))) {
return redirect()->intended($this->redirectPath());
}
return redirect('admin/auth/login')
->withInput($request->only('email'))
->withErrors([
'email' => 'These credentials do not match our records.'
]);
}
Laravel will check if the "active" column on the users table is equal to 1
$credentials['active'] = 1;
Down side you cannot say why the authentication failed. You have to stick to default error message.
Or you could check it before redirecting with something like this
$user = User::whereEmail($credentials['email'])->get()
if($user AND ! $user->active) {
\Session::flash('message', 'Please activate your account to proceed.');
}