Skip to content

Commit

Permalink
fixed login error for banned users
Browse files Browse the repository at this point in the history
  • Loading branch information
REJack committed Feb 21, 2020
1 parent ccabc9f commit 1489af6
Showing 1 changed file with 36 additions and 34 deletions.
70 changes: 36 additions & 34 deletions application/libraries/Aauth.php
Original file line number Diff line number Diff line change
Expand Up @@ -298,46 +298,48 @@ public function login($identifier, $pass, $remember = false, $totp_code = null)
$row = $query->row();

// if email and pass matches and not banned
$password = ($this->config_vars['use_password_hash'] ? $pass : $this->hash_password($pass, $row->id));

if ( $query->num_rows() != 0 && $this->verify_password($password, $row->pass) ) {

// If email and pass matches
// create session
$data = array(
'id' => $row->id,
'username' => $row->username,
'email' => $row->email,
'loggedin' => true
);
if ($query->num_rows() != 0) {
$password = ($this->config_vars['use_password_hash'] ? $pass : $this->hash_password($pass, $row->id));

if ($this->verify_password($password, $row->pass)) {
// If email and pass matches
// create session
$data = array(
'id' => $row->id,
'username' => $row->username,
'email' => $row->email,
'loggedin' => true
);

$this->CI->session->set_userdata($data);
$this->CI->session->set_userdata($data);

if ($remember){
$this->CI->load->helper('string');
$expire = $this->config_vars['remember'];
$today = date("Y-m-d");
$remember_date = date("Y-m-d", strtotime($today . $expire) );
$random_string = random_string('alnum', 16);
$this->update_remember($row->id, $random_string, $remember_date );
$cookie = array(
'name' => 'user',
'value' => $row->id . "-" . $random_string,
'expire' => 99*999*999,
'path' => '/',
);
$this->CI->input->set_cookie($cookie);
}

if ( $remember ){
$this->CI->load->helper('string');
$expire = $this->config_vars['remember'];
$today = date("Y-m-d");
$remember_date = date("Y-m-d", strtotime($today . $expire) );
$random_string = random_string('alnum', 16);
$this->update_remember($row->id, $random_string, $remember_date );
$cookie = array(
'name' => 'user',
'value' => $row->id . "-" . $random_string,
'expire' => 99*999*999,
'path' => '/',
);
$this->CI->input->set_cookie($cookie);
}
// update last login
$this->update_last_login($row->id);
$this->update_activity();

// update last login
$this->update_last_login($row->id);
$this->update_activity();
if($this->config_vars['remove_successful_attempts'] == true){
$this->reset_login_attempts();
}

if($this->config_vars['remove_successful_attempts'] == true){
$this->reset_login_attempts();
return true;
}

return true;
}
// if not matches
else {
Expand Down

0 comments on commit 1489af6

Please sign in to comment.