Beispiel #1
0
 /**
  * Set a new value for a password column of the database table.
  * The value is only saved in the object. You must call the method @b save to store the new value to the database
  * @param string $newPassword   The new value that should be stored in the database field
  * @param bool   $isNewPassword Should the column password or new_password be set
  * @param bool   $doHashing     Should the password get hashed before inserted. Default is true
  * @return bool Returns @b true if the value is stored in the current object and @b false if a check failed
  */
 public function setPassword($newPassword, $isNewPassword = false, $doHashing = true)
 {
     global $gPreferences;
     $columnName = 'usr_password';
     if ($isNewPassword) {
         $columnName = 'usr_new_password';
     }
     if ($doHashing) {
         // get the saved cost value that fits your server performance best and rehash your password
         $cost = 10;
         if (isset($gPreferences['system_hashing_cost'])) {
             $cost = intval($gPreferences['system_hashing_cost']);
         }
         $newPassword = PasswordHashing::hash($newPassword, PASSWORD_DEFAULT, array('cost' => $cost));
     }
     return parent::setValue($columnName, $newPassword, false);
 }