Skip to content

Commit

Permalink
Make sure the admin password is hashed when inserting the admin user …
Browse files Browse the repository at this point in the history
…on an already installed Vanilla.
  • Loading branch information
tburry committed Mar 2, 2013
1 parent 32aeeb5 commit c7748bf
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions applications/dashboard/models/class.usermodel.php
Expand Up @@ -152,7 +152,7 @@ protected function _Insert($Fields, $Options = array()) {
}

// Make sure to encrypt the password for saving...
if (array_key_exists('Password', $Fields)) {
if (array_key_exists('Password', $Fields) && !array_key_exists('HashMethod', $Fields)) {
$PasswordHash = new Gdn_PasswordHash();
$Fields['Password'] = $PasswordHash->HashPassword($Fields['Password']);
$Fields['HashMethod'] = 'Vanilla';
Expand Down Expand Up @@ -985,7 +985,12 @@ public function SaveAdminUser($FormPostValues) {
$Fields['UserID'] = 1;

if ($this->GetID($UserID) !== FALSE) {
$this->SQL->Put($this->Name, $Fields);
// Re-hash the password here.
$PasswordHash = new Gdn_PasswordHash();
$Fields['Password'] = $PasswordHash->HashPassword($Fields['Password']);
$Fields['HashMethod'] = 'Vanilla';

$this->SQL->Put($this->Name, $Fields, array('UserID' => 1));
} else {
// Insert the new user
$UserID = $this->_Insert($Fields, array('NoConfirmEmail' => TRUE));
Expand Down

0 comments on commit c7748bf

Please sign in to comment.