Path: blob/1.0-develop/app/Console/Commands/User/DisableTwoFactorCommand.php
7461 views
<?php12namespace Pterodactyl\Console\Commands\User;34use Illuminate\Console\Command;5use Pterodactyl\Contracts\Repository\UserRepositoryInterface;67class DisableTwoFactorCommand extends Command8{9protected $description = 'Disable two-factor authentication for a specific user in the Panel.';1011protected $signature = 'p:user:disable2fa {--email= : The email of the user to disable 2-Factor for.}';1213/**14* DisableTwoFactorCommand constructor.15*/16public function __construct(private UserRepositoryInterface $repository)17{18parent::__construct();19}2021/**22* Handle command execution process.23*24* @throws \Pterodactyl\Exceptions\Model\DataValidationException25* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException26*/27public function handle()28{29if ($this->input->isInteractive()) {30$this->output->warning(trans('command/messages.user.2fa_help_text'));31}3233$email = $this->option('email') ?? $this->ask(trans('command/messages.user.ask_email'));34$user = $this->repository->setColumns(['id', 'email'])->findFirstWhere([['email', '=', $email]]);3536$this->repository->withoutFreshModel()->update($user->id, [37'use_totp' => false,38'totp_secret' => null,39]);40$this->info(trans('command/messages.user.2fa_disabled', ['email' => $user->email]));41}42}434445