From 11288205faddb39b339e550fff55ade55609a317 Mon Sep 17 00:00:00 2001 From: Raphael Jackstadt Date: Wed, 20 May 2015 05:33:16 +0200 Subject: [PATCH] added totp_reset_over_reset_password and update_user_totp_secret() --- application/config/aauth.php | 2 ++ application/libraries/Aauth.php | 17 ++++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/application/config/aauth.php b/application/config/aauth.php index 9ec712c..d9d3858 100644 --- a/application/config/aauth.php +++ b/application/config/aauth.php @@ -58,6 +58,8 @@ $config['aauth']['recaptcha_siteKey'] = ''; $config['aauth']['recaptcha_secret'] = ''; $config['aauth']['totp_active'] = true; +$config['aauth']['totp_reset_over_reset_password'] = false; + // login attempts time interval // default 20 times in one hour $config['aauth']['max_login_attempt'] = 10; diff --git a/application/libraries/Aauth.php b/application/libraries/Aauth.php index 02f10a6..54fbeac 100644 --- a/application/libraries/Aauth.php +++ b/application/libraries/Aauth.php @@ -502,6 +502,10 @@ class Aauth { 'pass' => $this->hash_password($pass, $user_id) ); + if($this->config_vars['totp_active'] == TRUE AND $this->config_vars['totp_reset_over_reset_password'] == TRUE){ + $data['totp_secret'] = NULL; + } + $row = $query->row(); $email = $row->email; @@ -2131,7 +2135,18 @@ class Aauth { return $content; } - public function generate_totp_secret(){ + public function update_user_totp_secret($user_id = FALSE, $secret) { + + if ($user_id == FALSE) + $user_id = $this->CI->session->userdata('id'); + + $data['totp_secret'] = $secret; + + $this->aauth_db->where('id', $user_id); + return $this->aauth_db->update($this->config_vars['users'], $data); + } + + public function generate_unique_totp_secret(){ $ga = new PHPGangsta_GoogleAuthenticator(); $stop = false; while (!$stop) {