2017-09-16 23:50:12 +00:00
|
|
|
<?php
|
2017-09-26 02:43:01 +00:00
|
|
|
/**
|
2017-09-16 23:50:12 +00:00
|
|
|
* Pterodactyl - Panel
|
|
|
|
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
|
|
|
*
|
2017-09-26 02:43:01 +00:00
|
|
|
* This software is licensed under the terms of the MIT license.
|
|
|
|
* https://opensource.org/licenses/MIT
|
2017-09-16 23:50:12 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
namespace Pterodactyl\Console\Commands\User;
|
|
|
|
|
|
|
|
use Illuminate\Console\Command;
|
|
|
|
use Pterodactyl\Contracts\Repository\UserRepositoryInterface;
|
|
|
|
|
|
|
|
class DisableTwoFactorCommand extends Command
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $description = 'Disable two-factor authentication for a specific user in the Panel.';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var \Pterodactyl\Contracts\Repository\UserRepositoryInterface
|
|
|
|
*/
|
|
|
|
protected $repository;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $signature = 'p:user:disable2fa {--email= : The email of the user to disable 2-Factor for.}';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* DisableTwoFactorCommand constructor.
|
|
|
|
*
|
|
|
|
* @param \Pterodactyl\Contracts\Repository\UserRepositoryInterface $repository
|
|
|
|
*/
|
|
|
|
public function __construct(UserRepositoryInterface $repository)
|
|
|
|
{
|
|
|
|
parent::__construct();
|
|
|
|
|
|
|
|
$this->repository = $repository;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
|
|
|
$this->repository->withoutFresh()->update($user->id, [
|
|
|
|
'use_totp' => false,
|
|
|
|
'totp_secret' => null,
|
|
|
|
]);
|
|
|
|
$this->info(trans('command/messages.user.2fa_disabled', ['email' => $user->email]));
|
|
|
|
}
|
|
|
|
}
|