Welcome Guest, Not a member yet? Register   Sign In
flexi auth - A user authentication library for CodeIgniter
#67

[eluser]code_has_been_ignited[/eluser]
Hey,

What I guess what I do not understand is why it WILL show the error if im missing the username or password, because it will not pass the form_validation.

This is my function:

Code:
public function login()
{
// Set validation rules.
  $this->form_validation->set_rules('login_identity', 'Identity (Email / Login)', 'required');
  $this->form_validation->set_rules('login_password', 'Password', 'required');

  // If failed login attempts from users IP exceeds limit defined by config file, validate captcha.
  if ($this->flexi_auth->ip_login_attempts_exceeded())
  {
   $this->form_validation->set_rules('recaptcha_response_field', 'Captcha Answer', 'required|validate_recaptcha');      
  }
  
  // Run the validation.
  if ($this->form_validation->run())
  {
   // Check if user wants the 'Remember me' feature enabled.
   $remember_user = ($this->input->post('remember_me') == 1);

   // Verify login data.
   $this->flexi_auth->login($this->input->post('login_identity'), $this->input->post('login_password'), $remember_user);

   // Save any public status or error messages (Whilst suppressing any admin messages) to CI's flash session data.
   $this->session->set_flashdata('message', $this->flexi_auth->get_messages());

   // Reload page, if login was successful, sessions will have been created that will then further redirect verified users.
   redirect('account');
  }
  
   // Set validation errors.
   $this->data['message'] = validation_errors('<p class="error_msg">', '</p>');

  
  $this->data['message'] = (! isset($this->data['message'])) ? $this->session->flashdata('message') : $this->data['message'];
  $this->load->view('template/global_header');
  $this->load->view('public/login_form',$this->data);
  $this->load->view('template/global_footer');
}
In my view I have
Code:
&lt;?php if (! empty($message)) { ?&gt;
<div id="message">
  &lt;?php echo $message; ?&gt;
  </div>
&lt;?php } ?&gt;

The code is almost identical to the demo, with exception I process the login inside my controller.

Thanks for any tips and solutions

Will


Messages In This Thread
flexi auth - A user authentication library for CodeIgniter - by El Forum - 10-17-2012, 01:25 PM



Theme © iAndrew 2016 - Forum software by © MyBB