In authentication, in addition to the data required to log in, I want only those with status ativo = 1
to log in, but I do not know how to do this.
table user:
id
username
email
password
ativo
UserController
public function store()
{
$userdata = array(
'email' => Input::get('email'),
'password' => Input::get('password')
);
$rules = array(
'email' => 'required',
'password' => 'required'
);
$message = array(
'email.required' => 'O :attribute é obrigatório.',
'password.required' => 'A senha é obrigatória.'
);
$validator = Validator::make($userdata, $rules, $message);
if ($validator->passes())
{
if (Auth::attempt($userdata))
{
return Redirect::to('')->with('success', 'You have logged in successfully');
}
else
{
return Redirect::route('admin.create')->withErrors(array('password' => 'Senha inválida'))->withInput(Input::except('password'));
}
}
// Something went wrong.
return Redirect::route('admin.create')->withErrors($validator)->withInput(Input::except('password'));
}