Skip to content

Commit

Permalink
removed config var update_last_login_attempt
Browse files Browse the repository at this point in the history
changed `update_login_attempts()` (removed config var `update_last_login_attempt` & optimized if's)
  • Loading branch information
REJack committed May 14, 2016
1 parent f33affc commit fd6e3f3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 18 deletions.
1 change: 0 additions & 1 deletion application/config/aauth.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@

'max_login_attempt' => 10,
'max_login_attempt_per_minutes' => 5,
'update_last_login_attempt' => true,

'login_with_name' => false,

Expand Down
22 changes: 5 additions & 17 deletions application/libraries/Aauth.php
Original file line number Diff line number Diff line change
Expand Up @@ -635,30 +635,18 @@ public function update_login_attempts($email) {
$query = $this->aauth_db->get( $this->config_vars['users'] );
$row = $query->row();


$data = array();
$data['last_login_attempt'] = date("Y-m-d H:i:s");

$minutes = $this->config_vars['max_login_attempt_per_minutes'];
if (strtotime($row->last_login_attempt) > strtotime("-$minutes minutes")) {
if (strtotime($row->last_login_attempt) > strtotime("-".$this->config_vars['max_login_attempt_per_minutes'])) {
$data['login_attempts'] = $row->login_attempts + 1;

if($this->config_vars['update_last_login_attempt']){
$data['last_login_attempt'] = date("Y-m-d H:i:s");
}

$query = $this->aauth_db->where('id', $user_id);
$this->aauth_db->update($this->config_vars['users'], $data);

} else {

$data['last_login_attempt'] = date("Y-m-d H:i:s");
$data['login_attempts'] = 1;

$this->aauth_db->where('id', $user_id);
$this->aauth_db->update($this->config_vars['users'], $data);

}

$this->aauth_db->where('id', $user_id);
$this->aauth_db->update($this->config_vars['users'], $data);

if ( $data['login_attempts'] > $this->config_vars['max_login_attempt'] ) {
return FALSE;
} else {
Expand Down

0 comments on commit fd6e3f3

Please sign in to comment.