Files
pterodactyl-panel/app/Console/Commands/User/DisableTwoFactorCommand.php
T

36 lines
1.0 KiB
PHP
Raw Normal View History

<?php
2026-10-05 18:10:18 -04:00
declare(strict_types=1);
namespace Pterodactyl\Console\Commands\User;
2026-10-05 18:10:18 -04:00
use Illuminate\Console\Attributes\Description;
use Illuminate\Console\Attributes\Signature;
use Illuminate\Console\Command;
2026-10-05 18:10:18 -04:00
use Pterodactyl\Models\User;
2026-10-05 18:10:18 -04:00
#[Description('Disable two-factor authentication for a specific user in the Panel.')]
#[Signature('p:user:disable2fa {--email= : The email of the user to disable 2-Factor for.}')]
class DisableTwoFactorCommand extends Command
{
/**
* Handle command execution process.
*/
2026-10-05 18:10:18 -04:00
public function handle(): void
{
if ($this->input->isInteractive()) {
$this->output->warning(trans('command/messages.user.2fa_help_text'));
}
$email = $this->option('email') ?? $this->ask(trans('command/messages.user.ask_email'));
2026-10-05 18:10:18 -04:00
$user = User::query()->where('email', $email)->firstOrFail();
$user->update([
'use_totp' => false,
'totp_secret' => null,
]);
2026-10-05 18:10:18 -04:00
$this->info(trans('command/messages.user.2fa_disabled', ['email' => $user->email]));
}
}