userResourceModel = $userResourceModel; $this->userInterfaceFactory = $userFactory; $this->tfa = $tfa; } /** * @inheritdoc */ public function execute() { $userId = $this->getRequest()->getParam('id'); $providerCode = $this->getRequest()->getParam('provider'); $user = $this->userInterfaceFactory->create(); $this->userResourceModel->load($user, $userId); if (!$user->getId()) { throw new LocalizedException(__('Invalid user')); } $provider = $this->tfa->getProvider($providerCode); if (!$provider) { throw new LocalizedException(__('Unknown provider')); } $provider->resetConfiguration($user->getId()); $this->messageManager->addSuccessMessage(__('Configuration has been reset for this user')); return $this->_redirect('adminhtml/user/edit', ['user_id' => $userId]); } /** * @inheritdoc */ protected function _isAllowed() { return parent::_isAllowed() && $this->_authorization->isAllowed('MSP_TwoFactorAuth::tfa'); } }