8
In authentication beyond the data needed to log in the user, I want only those who are in status ativo = 1
log in, but I don’t know how to do this check.
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'));
}
Thank you Flávio H. Ferreira.
– João Mello