Put it on your controller
if ($this->form_validation->run() !== FALSE) { $remember = (bool) $this->input->post('remember'); $this->ion_auth_model->identity_column = 'username/email'; if ($this->ion_auth->login($this->input->post('username'), $this->input->post('password'), $remember)) { $this->session->set_flashdata('message', $this->ion_auth->messages()); } redirect('auth/login'); }
Edit ion_auth_model.php. find the login () function and update the code using the following code.
public function login($identity, $password, $remember=FALSE) { $this->trigger_events('pre_login'); if (empty($identity) || empty($password)) { $this->set_error('login_unsuccessful'); return FALSE; } $this->trigger_events('extra_where'); //just add this (starting this line) if ($this->identity_column == "username/email") { $fieldname = explode('/', $this->identity_column); $query = $this->db->select($fieldname[0] . ', username, email, id, password, active, last_login') ->where($fieldname[0], $identity) ->limit(1) ->get($this->tables['users']); $this->identity_column = $fieldname[0]; if ($query->num_rows() === 0) { $query = $this->db->select($fieldname[1] . ', username, email, id, password, active, last_login') ->where($fieldname[1], $identity) ->limit(1) ->get($this->tables['users']); $this->identity_column = $fieldname[1]; } } else { $query = $this->db->select($this->identity_column . ', username, email, id, password, active, last_login') ->where($this->identity_column, $identity) ->limit(1) ->get($this->tables['users']); } //up to this line if($this->is_time_locked_out($identity)) { //Hash something anyway, just to take up time $this->hash_password($password); $this->trigger_events('post_login_unsuccessful'); $this->set_error('login_timeout'); return FALSE; } if ($query->num_rows() === 1) { $user = $query->row(); $password = $this->hash_password_db($user->id, $password); if ($password === TRUE) { if ($user->active == 0) { $this->trigger_events('post_login_unsuccessful'); $this->set_error('login_unsuccessful_not_active'); return FALSE; } $this->set_session($user); $this->update_last_login($user->id); $this->clear_login_attempts($identity); if ($remember && $this->config->item('remember_users', 'ion_auth')) { $this->remember_user($user->id); } $this->trigger_events(array('post_login', 'post_login_successful')); $this->set_message('login_successful'); return TRUE; } } //Hash something anyway, just to take up time $this->hash_password($password); $this->increase_login_attempts($identity); $this->trigger_events('post_login_unsuccessful'); $this->set_error('login_unsuccessful'); return FALSE; }
source share