Search code examples
phpcodeigniterion-auth

Login with Ion Auth both Username and Email


I am using CodeIgniter. Now I have integrated Ion auth in CodeIgniter but I am facing the problem that how to log in with both Username and Email but ion auth accept only at a time with one identity to log in with Username OR Email. How to login with both username and email.


Solution

  • You have first goto ion_auth_model and search login function in ion_auth_model and you will see this line.

    $query = $this->db->select($this->identity_column .", ".$extraSelect.', email, id, password,active, last_login')
    

    Add username into this line

    $query = $this->db->select($this->identity_column .", ".$extraSelect.', username, email, id, password,active, last_login')
    

    After this add or_where() clause

    ->where($this->identity_column, $identity)
    ->or_where('username',$identity)
    ->limit(1)
    ->order_by('id', 'desc')
    ->get($this->tables['users']);