/**
* Display the specified resource.
*
* @param NA
* @return NA
*/
public function requestLogin()
{
// validate the info, create rules for the inputs
$rules = array('user_email' => 'required|email', 'password' => 'required|min:4');
// run the validation rules on the inputs from the form
$validator = Validator::make(Input::all(), $rules);
// if the validator fails, redirect back to the form
if ($validator->fails()) {
return Redirect::to(URL::previous())->withErrors($validator)->withInput(Input::except('password'));
// send back the input (not the password) so that we can repopulate the form
} else {
// create our user data for the authentication
$user_array = array('user_email' => $this->getInput('user_email', ''), 'password' => $this->getInput('password', ''));
// attempt to do the login
if (Auth::attempt($user_array)) {
$current_password = $this->getInput('password', '');
// additional validation to make sure that password matched
$user = Auth::user();
if (Hash::check($current_password, $user->password)) {
return Redirect::intended('check');
}
} else {
Input::flash();
Session::flash('error_message', 'Invalid email or password, please try again');
$this->data['has_error'] = ERROR;
return View::make('session.login')->with('data', $this->data);
}
}
}