diff --git a/application/config/aauth.php b/application/config/aauth.php index 285cc2d..46b7eaf 100644 --- a/application/config/aauth.php +++ b/application/config/aauth.php @@ -70,7 +70,7 @@ $config['aauth']['max_login_attempt'] = 10; $config['aauth']['verification'] = false; $config['aauth']['login_with_name'] = false; -$config['aauth']['use_cookies'] = false; +$config['aauth']['use_cookies'] = true; // FALSE only on CI3 // system email. $config['aauth']['email'] = 'admin@admin.com'; diff --git a/application/libraries/Aauth.php b/application/libraries/Aauth.php index 0a30bb2..3be029f 100644 --- a/application/libraries/Aauth.php +++ b/application/libraries/Aauth.php @@ -13,7 +13,7 @@ * * @copyright 2014-2015 Emre Akay * - * @version 2.3.3 + * @version 2.4.0 * * @license LGPL * @license http://opensource.org/licenses/LGPL-3.0 Lesser GNU Public License @@ -221,14 +221,15 @@ class Aauth { } $user_id = $query->row()->id; + if($this->config_vars['recaptcha_active']){ + if( ($this->config_vars['use_cookies'] == TRUE && $this->CI->input->cookie('reCAPTCHA', TRUE) == 'true') || ($this->config_vars['use_cookies'] == FALSE && $this->CI->session->tempdata('reCAPTCHA') == 'true') ){ + $reCaptcha = new ReCaptcha( $this->config_vars['recaptcha_secret']); + $resp = $reCaptcha->verifyResponse( $this->CI->input->server("REMOTE_ADDR"), $this->CI->input->post("g-recaptcha-response") ); - if( ($this->config_vars['use_cookies'] == TRUE && $this->CI->input->cookie('reCAPTCHA', TRUE) == 'true') || ($this->config_vars['use_cookies'] == FALSE && $this->CI->session->tempdata('reCAPTCHA') == 'true') ){ - $reCaptcha = new ReCaptcha( $this->config_vars['recaptcha_secret']); - $resp = $reCaptcha->verifyResponse( $this->CI->input->server("REMOTE_ADDR"), $this->CI->input->post("g-recaptcha-response") ); - - if(!$resp->success){ - $this->error($this->CI->lang->line('aauth_error_recaptcha_not_correct')); - return FALSE; + if(!$resp->success){ + $this->error($this->CI->lang->line('aauth_error_recaptcha_not_correct')); + return FALSE; + } } } @@ -2024,7 +2025,7 @@ class Aauth { if ($this->get_user_var($key,$user_id) ===FALSE) { $data = array( - 'key' => $key, + 'data_key' => $key, 'value' => $value, 'user_id' => $user_id ); @@ -2035,12 +2036,12 @@ class Aauth { else { $data = array( - 'key' => $key, + 'data_key' => $key, 'value' => $value, 'user_id' => $user_id ); - $this->aauth_db->where( 'key', $key ); + $this->aauth_db->where( 'data_key', $key ); $this->aauth_db->where( 'user_id', $user_id); return $this->aauth_db->update( $this->config_vars['user_variables'], $data); @@ -2065,7 +2066,7 @@ class Aauth { return FALSE; } - $this->aauth_db->where('key', $key); + $this->aauth_db->where('data_key', $key); $this->aauth_db->where('user_id', $user_id); return $this->aauth_db->delete( $this->config_vars['user_variables'] ); @@ -2091,7 +2092,7 @@ class Aauth { } $query = $this->aauth_db->where('user_id', $user_id); - $query = $this->aauth_db->where('key', $key); + $query = $this->aauth_db->where('data_key', $key); $query = $this->aauth_db->get( $this->config_vars['user_variables'] ); @@ -2123,7 +2124,7 @@ class Aauth { if ( ! $this->get_user($user_id)){ return FALSE; } - $query = $this->aauth_db->select('key'); + $query = $this->aauth_db->select('data_key'); $query = $this->aauth_db->where('user_id', $user_id); @@ -2155,7 +2156,7 @@ class Aauth { if ($this->get_system_var($key) === FALSE) { $data = array( - 'key' => $key, + 'data_key' => $key, 'value' => $value, ); @@ -2166,11 +2167,11 @@ class Aauth { else { $data = array( - 'key' => $key, + 'data_key' => $key, 'value' => $value, ); - $this->aauth_db->where( 'key', $key ); + $this->aauth_db->where( 'data_key', $key ); return $this->aauth_db->update( $this->config_vars['system_variables'], $data); } @@ -2184,7 +2185,7 @@ class Aauth { */ public function unset_system_var( $key ) { - $this->aauth_db->where('key', $key); + $this->aauth_db->where('data_key', $key); return $this->aauth_db->delete( $this->config_vars['system_variables'] ); } @@ -2198,7 +2199,7 @@ class Aauth { */ public function get_system_var( $key ){ - $query = $this->aauth_db->where('key', $key); + $query = $this->aauth_db->where('data_key', $key); $query = $this->aauth_db->get( $this->config_vars['system_variables'] ); @@ -2219,7 +2220,7 @@ class Aauth { */ public function list_system_var_keys(){ - $query = $this->aauth_db->select('key'); + $query = $this->aauth_db->select('data_key'); $query = $this->aauth_db->get( $this->config_vars['system_variables'] ); // if variable not set if ($query->num_rows() < 1) { return FALSE;} diff --git a/sql/Aauth_v2.sql b/sql/Aauth_v2.sql index 7696cb9..e5f20d3 100644 --- a/sql/Aauth_v2.sql +++ b/sql/Aauth_v2.sql @@ -91,7 +91,7 @@ CREATE TABLE `aauth_pms` ( DROP TABLE IF EXISTS `aauth_system_variables`; CREATE TABLE `aauth_system_variables` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, - `key` varchar(100) NOT NULL, + `data_key` varchar(100) NOT NULL, `value` text, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; @@ -151,7 +151,7 @@ DROP TABLE IF EXISTS `aauth_user_variables`; CREATE TABLE `aauth_user_variables` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `user_id` int(11) unsigned NOT NULL, - `key` varchar(100) NOT NULL, + `data_key` varchar(100) NOT NULL, `value` text, PRIMARY KEY (`id`), KEY `user_id_index` (`user_id`)