Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #207 from michaelbrooks/bcrypt-init

Bcrypt initialization happens several times
  • Loading branch information...
commit 2bfde31eab7d48eee896d9ab1a74d4ac084f8fe4 2 parents 5fcd75b + 4ec68d7
@benedmunds benedmunds authored
Showing with 17 additions and 15 deletions.
  1. +17 −15 models/ion_auth_model.php
View
32 models/ion_auth_model.php
@@ -179,6 +179,23 @@ public function __construct()
//initialize our hooks object
$this->_ion_hooks = new stdClass;
+ //load the bcrypt class if needed
+ if ($this->hash_method == 'bcrypt') {
+ if ($this->random_rounds)
+ {
+ $rand = rand($this->min_rounds,$this->max_rounds);
+ $rounds = array('rounds' => $rand);
+
+ }
+ else
+ {
+ $rounds = array('rounds' => $this->default_rounds);
+ }
+
+ $CI=& get_instance();
+ $CI->load->library('bcrypt',$rounds);
+ }
+
$this->trigger_events('model_constructor');
}
@@ -209,20 +226,7 @@ public function hash_password($password, $salt=false, $use_sha1_override=FALSE)
//bcrypt
if ($use_sha1_override === FALSE && $this->hash_method == 'bcrypt')
{
-
- if ($this->random_rounds)
- {
- $rand = rand($this->min_rounds,$this->max_rounds);
- $rounds = array('rounds' => $rand);
-
- }
- else
- {
- $rounds = array('rounds' => $this->default_rounds);
- }
-
$CI=& get_instance();
- $CI->load->library('bcrypt',$rounds);
return $CI->bcrypt->hash($password);
}
@@ -270,8 +274,6 @@ public function hash_password_db($id, $password, $use_sha1_override=FALSE)
if ($use_sha1_override === FALSE && $this->hash_method == 'bcrypt')
{
$CI=& get_instance();
- $CI->load->library('bcrypt',null);
-
if ($CI->bcrypt->verify($password,$hash_password_db->password))
{
return TRUE;
Please sign in to comment.
Something went wrong with that request. Please try again.