From c6408fd79d3a36fc04fec58e2d47e57997969dd3 Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Tue, 10 Oct 2023 20:00:12 -0600 Subject: [PATCH] Add user:2fa command to easily disable 2FA for given account --- app/Console/Commands/UserToggle2FA.php | 55 ++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 app/Console/Commands/UserToggle2FA.php diff --git a/app/Console/Commands/UserToggle2FA.php b/app/Console/Commands/UserToggle2FA.php new file mode 100644 index 000000000..c3b368608 --- /dev/null +++ b/app/Console/Commands/UserToggle2FA.php @@ -0,0 +1,55 @@ + 'Which username should we disable 2FA for?', + ]; + } + /** + * Execute the console command. + */ + public function handle() + { + $user = User::whereUsername($this->argument('username'))->first(); + + if(!$user->{'2fa_enabled'}) { + $this->info('User did not have 2FA enabled!'); + return; + } + + $user->{'2fa_enabled'} = false; + $user->{'2fa_secret'} = null; + $user->{'2fa_backup_codes'} = null; + $user->save(); + + $this->info('Successfully disabled 2FA on this account!'); + } +}