TfaDisable.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. /**
  3. * IDEALIAGroup srl
  4. *
  5. * NOTICE OF LICENSE
  6. *
  7. * This source file is subject to the Open Software License (OSL 3.0)
  8. * that is bundled with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://opensource.org/licenses/osl-3.0.php
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to info@idealiagroup.com so we can send you a copy immediately.
  14. *
  15. * @category MSP
  16. * @package MSP_TwoFactorAuth
  17. * @copyright Copyright (c) 2016 IDEALIAGroup srl (http://www.idealiagroup.com)
  18. * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
  19. */
  20. namespace MSP\TwoFactorAuth\Command;
  21. use Magento\Framework\App\Cache\Manager;
  22. use Magento\Framework\App\Config\ConfigResource\ConfigInterface;
  23. use Symfony\Component\Console\Command\Command;
  24. use Symfony\Component\Console\Input\InputInterface;
  25. use Symfony\Component\Console\Output\OutputInterface;
  26. use MSP\TwoFactorAuth\Api\TfaInterface;
  27. class TfaDisable extends Command
  28. {
  29. /**
  30. * @var ConfigInterface
  31. */
  32. private $config;
  33. /**
  34. * @var Manager
  35. */
  36. private $cacheManager;
  37. public function __construct(
  38. ConfigInterface $config,
  39. Manager $cacheManager
  40. ) {
  41. parent::__construct();
  42. $this->config = $config;
  43. $this->cacheManager = $cacheManager;
  44. }
  45. protected function configure()
  46. {
  47. $this->setName('msp:security:tfa:disable');
  48. $this->setDescription('Globally disable two factor auth');
  49. parent::configure();
  50. }
  51. /**
  52. * @SuppressWarnings("PHPMD.UnusedFormalParameter")
  53. */
  54. protected function execute(InputInterface $input, OutputInterface $output)
  55. {
  56. $this->config->saveConfig(
  57. TfaInterface::XML_PATH_ENABLED,
  58. '0',
  59. 'default',
  60. 0
  61. );
  62. $this->cacheManager->flush(['config']);
  63. }
  64. }