i want to give the user a visual feedback if they entered wrong login information.
public function doLogin()
{
$rules = array(
'email' => 'required|email',
'password' => 'required|min:3'
);
$validator = Validator::make(Input::all(), $rules);
if ($validator->fails()) {
return Redirect::route('login')
->withErrors($validator)
->withInput(Input::except('password'));
} else {
$userdata = array(
'email' => Input::get('email'),
'password' => Input::get('password')
);
if (Auth::attempt($userdata)) {
return Redirect::route('dashhome')
->withJsd('true');
} else {
return Redirect::route('login')
->withErrors(['wrongpw','Wrong E-mail address or Password']);
}
}
}
and on my login view i have this code
@if ($errors->has('wrongpw'))
<script>
$.gritter.add({
title: 'Ups!',
text: "{{ $errors->first('wrongpw') }}",
class_name: 'warning',
time: ''
});
</script>
@endif
But that doesn't work. Any idea what i make wrong or any suggestions on how to do it better?
Thanks