Skip to content

Commit

Permalink
Merge pull request benedmunds#357 from fbcpublishing/2
Browse files Browse the repository at this point in the history
Some naming changes, moved new password hashing into where it is needed.
  • Loading branch information
benedmunds committed Nov 22, 2012
2 parents f03131d + 5d83b34 commit 053af35
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions models/ion_auth_model.php
Original file line number Diff line number Diff line change
Expand Up @@ -561,24 +561,24 @@ public function change_password($identity, $old, $new)
return FALSE;
}

$result = $query->row();
$user = $query->row();

$old = $this->hash_password_db($result->id, $old);
$new = $this->hash_password($new, $result->salt);
$old_password_matches = $this->hash_password_db($user->id, $old);

if ($old === TRUE)
if ($old_password_matches === TRUE)
{
//store the new password and reset the remember code so all remembered instances have to re-login
$hashed_new_password = $this->hash_password($new, $user->salt);
$data = array(
'password' => $new,
'password' => $hashed_new_password,
'remember_code' => NULL,
);

$this->trigger_events('extra_where');
$this->db->update($this->tables['users'], $data, array($this->identity_column => $identity));

$return = $this->db->affected_rows() == 1;
if ($return)
$successfully_changed_password_in_db = $this->db->affected_rows() == 1;
if ($successfully_changed_password_in_db)
{
$this->trigger_events(array('post_change_password', 'post_change_password_successful'));
$this->set_message('password_change_successful');
Expand All @@ -589,7 +589,7 @@ public function change_password($identity, $old, $new)
$this->set_error('password_change_unsuccessful');
}

return $return;
return $successfully_changed_password_in_db;
}

$this->set_error('password_change_unsuccessful');
Expand Down

0 comments on commit 053af35

Please sign in to comment.