Upgrade to Laravel 9 (#4413)
Co-authored-by: DaneEveritt <dane@daneeveritt.com>
This commit is contained in:
parent
95e15d2c8a
commit
cbcf62086f
573 changed files with 4387 additions and 9411 deletions
|
@ -14,53 +14,21 @@ use Pterodactyl\Exceptions\Service\User\TwoFactorAuthenticationTokenInvalid;
|
|||
|
||||
class ToggleTwoFactorService
|
||||
{
|
||||
/**
|
||||
* @var \Illuminate\Contracts\Encryption\Encrypter
|
||||
*/
|
||||
private $encrypter;
|
||||
|
||||
/**
|
||||
* @var \PragmaRX\Google2FA\Google2FA
|
||||
*/
|
||||
private $google2FA;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\UserRepositoryInterface
|
||||
*/
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Repositories\Eloquent\RecoveryTokenRepository
|
||||
*/
|
||||
private $recoveryTokenRepository;
|
||||
|
||||
/**
|
||||
* @var \Illuminate\Database\ConnectionInterface
|
||||
*/
|
||||
private $connection;
|
||||
|
||||
/**
|
||||
* ToggleTwoFactorService constructor.
|
||||
*/
|
||||
public function __construct(
|
||||
ConnectionInterface $connection,
|
||||
Encrypter $encrypter,
|
||||
Google2FA $google2FA,
|
||||
RecoveryTokenRepository $recoveryTokenRepository,
|
||||
UserRepositoryInterface $repository
|
||||
private ConnectionInterface $connection,
|
||||
private Encrypter $encrypter,
|
||||
private Google2FA $google2FA,
|
||||
private RecoveryTokenRepository $recoveryTokenRepository,
|
||||
private UserRepositoryInterface $repository
|
||||
) {
|
||||
$this->encrypter = $encrypter;
|
||||
$this->google2FA = $google2FA;
|
||||
$this->repository = $repository;
|
||||
$this->recoveryTokenRepository = $recoveryTokenRepository;
|
||||
$this->connection = $connection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle 2FA on an account only if the token provided is valid.
|
||||
*
|
||||
* @return string[]
|
||||
*
|
||||
* @throws \Throwable
|
||||
* @throws \PragmaRX\Google2FA\Exceptions\IncompatibleWithGoogleAuthenticatorException
|
||||
* @throws \PragmaRX\Google2FA\Exceptions\InvalidCharactersException
|
||||
|
|
|
@ -13,32 +13,14 @@ class TwoFactorSetupService
|
|||
{
|
||||
public const VALID_BASE32_CHARACTERS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567';
|
||||
|
||||
/**
|
||||
* @var \Illuminate\Contracts\Config\Repository
|
||||
*/
|
||||
private $config;
|
||||
|
||||
/**
|
||||
* @var \Illuminate\Contracts\Encryption\Encrypter
|
||||
*/
|
||||
private $encrypter;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\UserRepositoryInterface
|
||||
*/
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* TwoFactorSetupService constructor.
|
||||
*/
|
||||
public function __construct(
|
||||
ConfigRepository $config,
|
||||
Encrypter $encrypter,
|
||||
UserRepositoryInterface $repository
|
||||
private ConfigRepository $config,
|
||||
private Encrypter $encrypter,
|
||||
private UserRepositoryInterface $repository
|
||||
) {
|
||||
$this->config = $config;
|
||||
$this->encrypter = $encrypter;
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
namespace Pterodactyl\Services\Users;
|
||||
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Pterodactyl\Models\User;
|
||||
use Illuminate\Contracts\Hashing\Hasher;
|
||||
use Illuminate\Database\ConnectionInterface;
|
||||
use Illuminate\Contracts\Auth\PasswordBroker;
|
||||
|
@ -12,49 +13,23 @@ use Pterodactyl\Contracts\Repository\UserRepositoryInterface;
|
|||
class UserCreationService
|
||||
{
|
||||
/**
|
||||
* @var \Illuminate\Database\ConnectionInterface
|
||||
*/
|
||||
private $connection;
|
||||
|
||||
/**
|
||||
* @var \Illuminate\Contracts\Hashing\Hasher
|
||||
*/
|
||||
private $hasher;
|
||||
|
||||
/**
|
||||
* @var \Illuminate\Contracts\Auth\PasswordBroker
|
||||
*/
|
||||
private $passwordBroker;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\UserRepositoryInterface
|
||||
*/
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* CreationService constructor.
|
||||
* UserCreationService constructor.
|
||||
*/
|
||||
public function __construct(
|
||||
ConnectionInterface $connection,
|
||||
Hasher $hasher,
|
||||
PasswordBroker $passwordBroker,
|
||||
UserRepositoryInterface $repository
|
||||
private ConnectionInterface $connection,
|
||||
private Hasher $hasher,
|
||||
private PasswordBroker $passwordBroker,
|
||||
private UserRepositoryInterface $repository
|
||||
) {
|
||||
$this->connection = $connection;
|
||||
$this->hasher = $hasher;
|
||||
$this->passwordBroker = $passwordBroker;
|
||||
$this->repository = $repository;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new user on the system.
|
||||
*
|
||||
* @return \Pterodactyl\Models\User
|
||||
*
|
||||
* @throws \Exception
|
||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||
*/
|
||||
public function handle(array $data)
|
||||
public function handle(array $data): User
|
||||
{
|
||||
if (array_key_exists('password', $data) && !empty($data['password'])) {
|
||||
$data['password'] = $this->hasher->make($data['password']);
|
||||
|
|
|
@ -1,13 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Pterodactyl - Panel
|
||||
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
|
||||
*
|
||||
* This software is licensed under the terms of the MIT license.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
namespace Pterodactyl\Services\Users;
|
||||
|
||||
use Pterodactyl\Models\User;
|
||||
|
@ -19,43 +11,21 @@ use Pterodactyl\Contracts\Repository\ServerRepositoryInterface;
|
|||
class UserDeletionService
|
||||
{
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\UserRepositoryInterface
|
||||
*/
|
||||
protected $repository;
|
||||
|
||||
/**
|
||||
* @var \Illuminate\Contracts\Translation\Translator
|
||||
*/
|
||||
protected $translator;
|
||||
|
||||
/**
|
||||
* @var \Pterodactyl\Contracts\Repository\ServerRepositoryInterface
|
||||
*/
|
||||
protected $serverRepository;
|
||||
|
||||
/**
|
||||
* DeletionService constructor.
|
||||
* UserDeletionService constructor.
|
||||
*/
|
||||
public function __construct(
|
||||
ServerRepositoryInterface $serverRepository,
|
||||
Translator $translator,
|
||||
UserRepositoryInterface $repository
|
||||
protected UserRepositoryInterface $repository,
|
||||
protected ServerRepositoryInterface $serverRepository,
|
||||
protected Translator $translator
|
||||
) {
|
||||
$this->repository = $repository;
|
||||
$this->translator = $translator;
|
||||
$this->serverRepository = $serverRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a user from the panel only if they have no servers attached to their account.
|
||||
*
|
||||
* @param int|\Pterodactyl\Models\User $user
|
||||
*
|
||||
* @return bool|null
|
||||
*
|
||||
* @throws \Pterodactyl\Exceptions\DisplayException
|
||||
*/
|
||||
public function handle($user)
|
||||
public function handle(int|User $user): ?bool
|
||||
{
|
||||
if ($user instanceof User) {
|
||||
$user = $user->id;
|
||||
|
|
|
@ -11,16 +11,10 @@ class UserUpdateService
|
|||
use HasUserLevels;
|
||||
|
||||
/**
|
||||
* @var \Illuminate\Contracts\Hashing\Hasher
|
||||
* UserUpdateService constructor.
|
||||
*/
|
||||
private $hasher;
|
||||
|
||||
/**
|
||||
* UpdateService constructor.
|
||||
*/
|
||||
public function __construct(Hasher $hasher)
|
||||
public function __construct(private Hasher $hasher)
|
||||
{
|
||||
$this->hasher = $hasher;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Reference in a new issue