Browse Source

v2.5.7

- fixed login remember
 - removed `use_cookies`-config_var (unused since reCAPTCHA doesnt use cookie/session)
 - changed `logout()`
 - changed `is_loggedin()` removed wrong session checks
develop
REJack 9 years ago
parent
commit
34d8a896b8
  1. 4
      application/config/aauth.php
  2. 45
      application/libraries/Aauth.php

4
application/config/aauth.php

@ -59,8 +59,6 @@ defined('BASEPATH') OR exit('No direct script access allowed');
| |
| ['login_with_name'] Login Identificator, if TRUE username needed to login else email address. | ['login_with_name'] Login Identificator, if TRUE username needed to login else email address.
| |
| ['use_cookies'] FALSE only on CI3
|
| ['email'] Sender email address, used for remind_password, send_verification and reset_password | ['email'] Sender email address, used for remind_password, send_verification and reset_password
| ['name'] Sender name, used for remind_password, send_verification and reset_password | ['name'] Sender name, used for remind_password, send_verification and reset_password
| ['email_config'] Array of Config for CI's Email Library | ['email_config'] Array of Config for CI's Email Library
@ -132,8 +130,6 @@ $config_aauth["default"] = array(
'login_with_name' => false, 'login_with_name' => false,
'use_cookies' => true,
'email' => 'admin@admin.com', 'email' => 'admin@admin.com',
'name' => 'Emre Akay', 'name' => 'Emre Akay',
'email_config' => false, 'email_config' => false,

45
application/libraries/Aauth.php

@ -13,7 +13,7 @@
* *
* @copyright 2014-2016 Emre Akay * @copyright 2014-2016 Emre Akay
* *
* @version 2.5.6 * @version 2.5.7
* *
* @license LGPL * @license LGPL
* @license http://opensource.org/licenses/LGPL-3.0 Lesser GNU Public License * @license http://opensource.org/licenses/LGPL-3.0 Lesser GNU Public License
@ -131,7 +131,6 @@ class Aauth {
*/ */
public function login($identifier, $pass, $remember = FALSE, $totp_code = NULL) { public function login($identifier, $pass, $remember = FALSE, $totp_code = NULL) {
if($this->config_vars['use_cookies'] == TRUE){
// Remove cookies first // Remove cookies first
$cookie = array( $cookie = array(
'name' => 'user', 'name' => 'user',
@ -140,7 +139,6 @@ class Aauth {
'path' => '/', 'path' => '/',
); );
$this->CI->input->set_cookie($cookie); $this->CI->input->set_cookie($cookie);
}
if ($this->config_vars['ddos_protection'] && ! $this->update_login_attempts()) { if ($this->config_vars['ddos_protection'] && ! $this->update_login_attempts()) {
$this->error($this->CI->lang->line('aauth_error_login_attempts_exceeded')); $this->error($this->CI->lang->line('aauth_error_login_attempts_exceeded'));
@ -271,26 +269,19 @@ class Aauth {
$this->CI->session->set_userdata($data); $this->CI->session->set_userdata($data);
// if remember selected
if ( $remember ){ if ( $remember ){
$expire = $this->config_vars['remember']; $expire = $this->config_vars['remember'];
$today = date("Y-m-d"); $today = date("Y-m-d");
$remember_date = date("Y-m-d", strtotime($today . $expire) ); $remember_date = date("Y-m-d", strtotime($today . $expire) );
$random_string = random_string('alnum', 16); $random_string = random_string('alnum', 16);
$this->update_remember($row->id, $random_string, $remember_date ); $this->update_remember($row->id, $random_string, $remember_date );
if($this->config_vars['use_cookies'] == TRUE){
$cookie = array( $cookie = array(
'name' => 'user', 'name' => 'user',
'value' => $row->id . "-" . $random_string, 'value' => $row->id . "-" . $random_string,
'expire' => 99*999*999, 'expire' => 99*999*999,
'path' => '/', 'path' => '/',
); );
$this->CI->input->set_cookie($cookie); $this->CI->input->set_cookie($cookie);
}else{
$this->CI->session->set_userdata('remember', $row->id . "-" . $random_string);
}
} }
// update last login // update last login
@ -322,7 +313,6 @@ class Aauth {
if ( $this->CI->session->userdata('loggedin') ){ if ( $this->CI->session->userdata('loggedin') ){
return TRUE; return TRUE;
} else { } else {
if($this->config_vars['use_cookies'] == TRUE){
if( ! $this->CI->input->cookie('user', TRUE) ){ if( ! $this->CI->input->cookie('user', TRUE) ){
return FALSE; return FALSE;
} else { } else {
@ -351,37 +341,6 @@ class Aauth {
} }
} }
} }
}else{
if(!isset($_SESSION['remember'])){
return FALSE;
}else{
$session = explode('-', $this->CI->session->userdata('remember'));
if(!is_numeric( $session[0] ) OR strlen($session[1]) < 13 ){return FALSE;}
else{
$query = $this->aauth_db->where('id', $session[0]);
$query = $this->aauth_db->where('remember_exp', $session[1]);
$query = $this->aauth_db->get($this->config_vars['users']);
$row = $query->row();
if ($query->num_rows() < 1) {
$this->update_remember($session[0]);
return FALSE;
}else{
if(strtotime($row->remember_time) > strtotime("now") ){
$this->login_fast($session[0]);
return TRUE;
}
// if time is expired
else {
return FALSE;
}
}
}
}
}
} }
return FALSE; return FALSE;
} }
@ -436,7 +395,6 @@ class Aauth {
*/ */
public function logout() { public function logout() {
if($this->config_vars['use_cookies'] == TRUE){
$cookie = array( $cookie = array(
'name' => 'user', 'name' => 'user',
'value' => '', 'value' => '',
@ -444,7 +402,6 @@ class Aauth {
'path' => '/', 'path' => '/',
); );
$this->CI->input->set_cookie($cookie); $this->CI->input->set_cookie($cookie);
}
return $this->CI->session->sess_destroy(); return $this->CI->session->sess_destroy();
} }

Loading…
Cancel
Save