Loading composer.json +1 −1 Original line number Diff line number Diff line Loading @@ -13,7 +13,7 @@ "extra": { "drush": { "services": { "drush.services.yml": "^9" "drush.services.yml": "^9 || ^10 || ^11" } } } Loading drush.services.yml +1 −0 Original line number Diff line number Diff line services: tfa.commands: class: \Drupal\tfa\Commands\TfaCommands arguments: ['@database'] tags: - { name: drush.command } src/Commands/TfaCommands.php +30 −3 Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ namespace Drupal\tfa\Commands; use Consolidation\AnnotatedCommand\CommandData; use Drupal\Core\Database\Connection; use Drush\Commands\DrushCommands; use Drush\Drupal\Commands\sql\SanitizePluginInterface; use Symfony\Component\Console\Input\InputInterface; Loading @@ -13,20 +14,46 @@ use Symfony\Component\Console\Input\InputInterface; class TfaCommands extends DrushCommands implements SanitizePluginInterface { /** * Database service. * * @var \Drupal\Core\Database\Connection */ protected $database; /** * TfaCommands constructor. * * @param \Drupal\Core\Database\Connection $database * The database service. */ public function __construct(Connection $database) { parent::__construct(); $this->database = $database; } /** * Sanitize recovery codes and user-specific TFA data. * * @hook post-command sql-sanitize * * {@inheritdoc} */ public function sanitize($result, CommandData $commandData) { // DBTNG does not support expressions in delete queries. $sql = "DELETE FROM users_data WHERE LEFT(name, 4) = 'tfa_'"; \Drupal::service('database')->query($sql); $this->database->query($sql); $this->logger()->success('Removed recovery codes and other user-specific TFA data.'); } /** * Display summary to user before confirmation. * * @hook on-event sql-sanitize-confirms * * {@inheritdoc} */ public function messages(&$messages, InputInterface $input) { return $messages[] = dt('Remove recovery codes and other user-specific TFA data.'); public function messages(array &$messages, InputInterface $input) { $messages[] = dt('Remove recovery codes and other user-specific TFA data.'); } } Loading
composer.json +1 −1 Original line number Diff line number Diff line Loading @@ -13,7 +13,7 @@ "extra": { "drush": { "services": { "drush.services.yml": "^9" "drush.services.yml": "^9 || ^10 || ^11" } } } Loading
drush.services.yml +1 −0 Original line number Diff line number Diff line services: tfa.commands: class: \Drupal\tfa\Commands\TfaCommands arguments: ['@database'] tags: - { name: drush.command }
src/Commands/TfaCommands.php +30 −3 Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ namespace Drupal\tfa\Commands; use Consolidation\AnnotatedCommand\CommandData; use Drupal\Core\Database\Connection; use Drush\Commands\DrushCommands; use Drush\Drupal\Commands\sql\SanitizePluginInterface; use Symfony\Component\Console\Input\InputInterface; Loading @@ -13,20 +14,46 @@ use Symfony\Component\Console\Input\InputInterface; class TfaCommands extends DrushCommands implements SanitizePluginInterface { /** * Database service. * * @var \Drupal\Core\Database\Connection */ protected $database; /** * TfaCommands constructor. * * @param \Drupal\Core\Database\Connection $database * The database service. */ public function __construct(Connection $database) { parent::__construct(); $this->database = $database; } /** * Sanitize recovery codes and user-specific TFA data. * * @hook post-command sql-sanitize * * {@inheritdoc} */ public function sanitize($result, CommandData $commandData) { // DBTNG does not support expressions in delete queries. $sql = "DELETE FROM users_data WHERE LEFT(name, 4) = 'tfa_'"; \Drupal::service('database')->query($sql); $this->database->query($sql); $this->logger()->success('Removed recovery codes and other user-specific TFA data.'); } /** * Display summary to user before confirmation. * * @hook on-event sql-sanitize-confirms * * {@inheritdoc} */ public function messages(&$messages, InputInterface $input) { return $messages[] = dt('Remove recovery codes and other user-specific TFA data.'); public function messages(array &$messages, InputInterface $input) { $messages[] = dt('Remove recovery codes and other user-specific TFA data.'); } }