2017-09-16 23:50:12 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Pterodactyl\Console\Commands\User;
|
|
|
|
|
|
|
|
use Illuminate\Console\Command;
|
|
|
|
use Pterodactyl\Contracts\Repository\UserRepositoryInterface;
|
|
|
|
|
|
|
|
class DisableTwoFactorCommand extends Command
|
|
|
|
{
|
|
|
|
protected $description = 'Disable two-factor authentication for a specific user in the Panel.';
|
|
|
|
|
|
|
|
protected $signature = 'p:user:disable2fa {--email= : The email of the user to disable 2-Factor for.}';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* DisableTwoFactorCommand constructor.
|
|
|
|
*/
|
2022-10-14 16:59:20 +00:00
|
|
|
public function __construct(private UserRepositoryInterface $repository)
|
2017-09-16 23:50:12 +00:00
|
|
|
{
|
|
|
|
parent::__construct();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle command execution process.
|
|
|
|
*
|
|
|
|
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
|
|
|
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
|
|
|
*/
|
|
|
|
public function handle()
|
|
|
|
{
|
|
|
|
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'));
|
2018-01-05 04:49:50 +00:00
|
|
|
$user = $this->repository->setColumns(['id', 'email'])->findFirstWhere([['email', '=', $email]]);
|
2017-09-16 23:50:12 +00:00
|
|
|
|
2018-01-05 22:33:50 +00:00
|
|
|
$this->repository->withoutFreshModel()->update($user->id, [
|
2017-09-16 23:50:12 +00:00
|
|
|
'use_totp' => false,
|
|
|
|
'totp_secret' => null,
|
|
|
|
]);
|
|
|
|
$this->info(trans('command/messages.user.2fa_disabled', ['email' => $user->email]));
|
|
|
|
}
|
|
|
|
}
|