Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/Drupal/Commands/sql/SanitizeUserTableCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Drupal\Core\Database\Database;
use Drush\Commands\DrushCommands;
use Drush\Sql\SqlBase;
use Drush\Utils\StringUtils;
use Symfony\Component\Console\Input\InputInterface;

/**
Expand Down Expand Up @@ -39,8 +40,13 @@ public function sanitize($result, CommandData $commandData)

// Sanitize passwords.
if ($this->isEnabled($options['sanitize-password'])) {
$password = $options['sanitize-password'];
if (is_null($password)) {
$password = StringUtils::generatePassword();
}

// Mimic Drupal's /scripts/password-hash.sh
$hash = $this->passwordHasher->hash($options['sanitize-password']);
$hash = $this->passwordHasher->hash($password);
$query->fields(['pass' => $hash]);
$messages[] = dt('User passwords sanitized.');
}
Expand Down Expand Up @@ -86,7 +92,7 @@ public function sanitize($result, CommandData $commandData)
* @option sanitize-password The password to assign to all accounts in the
* sanitization operation, or "no" to keep passwords unchanged.
*/
public function options($options = ['sanitize-email' => 'user+%[email protected]', 'sanitize-password' => 'password'])
public function options($options = ['sanitize-email' => 'user+%[email protected]', 'sanitize-password' => NULL])
{
}

Expand Down