You need change login()
method in application/controllers/auth.php
.
I'm think you need add to login()
method before redirect call something like this:
$location = '';
if($this->form_validation->run() == true)
{
//check to see if the user is logging in
//check for "remember me"
$remember = (bool) $this->input->post('remember');
if ($this->ion_auth->login($this->input->post('identity'), $this->input->post('password'), $remember))
{
//if the login is successful
//redirect them back to the home page
$this->session->set_flashdata('message', $this->ion_auth->messages());
$data = $this->ion_auth->messages();
$location = '/';
}
else
{
$this->session->set_flashdata('message', $this->ion_auth->errors());
$data = $this->ion_auth->errors();
$location = 'auth/login';
}
}
else
{
$this->data['message'] = (validation_errors()) ? validation_errors() : $this->session->flashdata('message');
$this->data['identity'] = array('name' => 'identity',
'id' => 'identity',
'type' => 'text',
'value' => $this->form_validation->set_value('identity'),
);
$this->data['password'] = array('name' => 'password',
'id' => 'password',
'type' => 'password',
);
$data = $this->data;
}
if($this->input->is_ajax_request())
{
echo json_encode(array('data' => $data));
}
else
{
($location) ? redirect($location, 'refresh') : $this->_render_page('auth/login', $data);
}
And add js code to handle response from login()
method.