Cleanup.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OC\Core\Command\TwoFactorAuth;
  8. use OCP\Authentication\TwoFactorAuth\IRegistry;
  9. use OCP\IUserManager;
  10. use Symfony\Component\Console\Input\InputArgument;
  11. use Symfony\Component\Console\Input\InputInterface;
  12. use Symfony\Component\Console\Output\OutputInterface;
  13. class Cleanup extends Base {
  14. public function __construct(
  15. private IRegistry $registry,
  16. IUserManager $userManager,
  17. ) {
  18. parent::__construct(
  19. null,
  20. $userManager,
  21. );
  22. }
  23. protected function configure() {
  24. parent::configure();
  25. $this->setName('twofactorauth:cleanup');
  26. $this->setDescription('Clean up the two-factor user-provider association of an uninstalled/removed provider');
  27. $this->addArgument('provider-id', InputArgument::REQUIRED);
  28. }
  29. protected function execute(InputInterface $input, OutputInterface $output): int {
  30. $providerId = $input->getArgument('provider-id');
  31. $this->registry->cleanUp($providerId);
  32. $output->writeln("<info>All user-provider associations for provider <options=bold>$providerId</> have been removed.</info>");
  33. return 0;
  34. }
  35. }