Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pterodactyl
GitHub Repository: pterodactyl/panel
Path: blob/1.0-develop/app/Console/Commands/User/DisableTwoFactorCommand.php
7461 views
1
<?php
2
3
namespace Pterodactyl\Console\Commands\User;
4
5
use Illuminate\Console\Command;
6
use Pterodactyl\Contracts\Repository\UserRepositoryInterface;
7
8
class DisableTwoFactorCommand extends Command
9
{
10
protected $description = 'Disable two-factor authentication for a specific user in the Panel.';
11
12
protected $signature = 'p:user:disable2fa {--email= : The email of the user to disable 2-Factor for.}';
13
14
/**
15
* DisableTwoFactorCommand constructor.
16
*/
17
public function __construct(private UserRepositoryInterface $repository)
18
{
19
parent::__construct();
20
}
21
22
/**
23
* Handle command execution process.
24
*
25
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
26
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
27
*/
28
public function handle()
29
{
30
if ($this->input->isInteractive()) {
31
$this->output->warning(trans('command/messages.user.2fa_help_text'));
32
}
33
34
$email = $this->option('email') ?? $this->ask(trans('command/messages.user.ask_email'));
35
$user = $this->repository->setColumns(['id', 'email'])->findFirstWhere([['email', '=', $email]]);
36
37
$this->repository->withoutFreshModel()->update($user->id, [
38
'use_totp' => false,
39
'totp_secret' => null,
40
]);
41
$this->info(trans('command/messages.user.2fa_disabled', ['email' => $user->email]));
42
}
43
}
44
45