From 63387fa9cfdb8bd20356fce9729a5a49a9f78bb9 Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Tue, 12 Apr 2016 22:26:44 -0400 Subject: Added command line utility to reset user password and to disable 2FA --- app/Console/ResetTwoFactorCommand.php | 38 +++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 app/Console/ResetTwoFactorCommand.php (limited to 'app/Console/ResetTwoFactorCommand.php') diff --git a/app/Console/ResetTwoFactorCommand.php b/app/Console/ResetTwoFactorCommand.php new file mode 100644 index 00000000..3bf01e81 --- /dev/null +++ b/app/Console/ResetTwoFactorCommand.php @@ -0,0 +1,38 @@ +setName('user:reset-2fa') + ->setDescription('Remove two-factor authentication for a user') + ->addArgument('username', InputArgument::REQUIRED, 'Username'); + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $username = $input->getArgument('username'); + $userId = $this->user->getIdByUsername($username); + + if (empty($userId)) { + $output->writeln('User not found'); + return false; + } + + if (!$this->user->update(array('id' => $userId, 'twofactor_activated' => 0, 'twofactor_secret' => ''))) { + $output->writeln('Unable to update user profile'); + return false; + } + + $output->writeln('Two-factor authentication disabled'); + + return true; + } +} -- cgit v1.2.3