upgrade to laravel 12.x

This commit is contained in:
robert dennis
2026-07-28 04:44:29 +09:00
parent 4434733461
commit 1d791ad615
9 changed files with 1171 additions and 1051 deletions
@@ -2,7 +2,6 @@
namespace Pterodactyl\Http\Requests\Api\Client\Servers\Subusers;
use Pterodactyl\Rules\UserEmail;
use Pterodactyl\Models\Permission;
class StoreSubuserRequest extends SubuserRequest
@@ -15,7 +14,7 @@ class StoreSubuserRequest extends SubuserRequest
public function rules(): array
{
return [
'email' => ['required', 'email:strict', 'between:1,191', new UserEmail()],
'email' => 'required|email:strict|between:1,191',
'permissions' => 'required|array',
'permissions.*' => 'string',
];
-2
View File
@@ -3,7 +3,6 @@
namespace Pterodactyl\Models;
use Pterodactyl\Rules\Username;
use Pterodactyl\Rules\UserEmail;
use Pterodactyl\Facades\Activity;
use Illuminate\Support\Collection;
use Illuminate\Validation\Rules\In;
@@ -190,7 +189,6 @@ class User extends Model implements
$rules['language'][] = new In(array_keys((new self())->getAvailableLanguages()));
$rules['username'][] = new Username();
$rules['email'][] = new UserEmail();
return $rules;
}
-33
View File
@@ -1,33 +0,0 @@
<?php
namespace Pterodactyl\Rules;
use Illuminate\Contracts\Validation\Rule;
class UserEmail implements Rule
{
/**
* @param string $attribute
*/
public function passes($attribute, $value): bool
{
if (!is_string($value)) {
return true;
}
$local = explode('@', $value, 2)[0] ?? '';
$local = trim($local, '"');
return !str_starts_with($local, '-');
}
public function message(): string
{
return 'The :attribute must not start with a dash.';
}
public function __toString(): string
{
return 'p_user_email';
}
}
+5 -5
View File
@@ -28,16 +28,16 @@
"guzzlehttp/guzzle": "^7.9.2",
"hashids/hashids": "^5.0.2",
"laracasts/utilities": "~3.2.3",
"laravel/framework": "^11.31.0",
"laravel/framework": "^12.60.0",
"laravel/helpers": "^1.8.0",
"laravel/sanctum": "^4.2.0",
"laravel/tinker": "^2.10.0",
"laravel/ui": "~4.5.2",
"laravel/ui": "~4.6.3",
"lcobucci/jwt": "^5.6.0",
"league/flysystem-aws-s3-v3": "^3.30.1",
"league/flysystem-memory": "^3.29.0",
"matriphe/iso-639": "~2.0",
"phpseclib/phpseclib": "^3.0.47",
"phpseclib/phpseclib": "^3.0.52",
"pragmarx/google2fa": "~8.0.3",
"predis/predis": "^3.3.0",
"prologue/alerts": "^1.3.0",
@@ -59,10 +59,10 @@
"itsgoingd/clockwork": "^5.3",
"larastan/larastan": "^3.8",
"mockery/mockery": "^1.6",
"nunomaduro/collision": "^8.5",
"nunomaduro/collision": "^8.9",
"phpstan/phpstan": "^2.1",
"phpstan/phpstan-webmozart-assert": "^2.0",
"phpunit/phpunit": "^10.5.62",
"phpunit/phpunit": "^11.5",
"spatie/laravel-ignition": "^2.9"
},
"autoload": {
Generated
+1164 -956
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" bootstrap="bootstrap/tests.php" colors="true">
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.5/phpunit.xsd" bootstrap="bootstrap/tests.php" colors="true">
<testsuites>
<testsuite name="Integration">
<directory>./tests/Integration</directory>
@@ -235,19 +235,6 @@ class UserControllerTest extends ApplicationApiIntegrationTestCase
$this->assertActivityFor('user:user.create', $this->getApiUser(), $user);
}
public function testCreateUserRejectsDashPrefixedEmail()
{
$response = $this->postJson('/api/application/users', [
'username' => 'dashuser',
'email' => '-x@example.com',
'first_name' => 'Test',
'last_name' => 'User',
]);
$response->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY);
$this->assertDatabaseMissing('users', ['email' => '-x@example.com']);
}
/**
* Test that a user can be updated.
*/
@@ -277,21 +264,6 @@ class UserControllerTest extends ApplicationApiIntegrationTestCase
]);
}
public function testUpdateUserRejectsDashPrefixedEmail()
{
$user = User::factory()->create();
$response = $this->patchJson('/api/application/users/' . $user->id, [
'username' => $user->username,
'email' => '-x@example.com',
'first_name' => $user->name_first,
'last_name' => $user->name_last,
]);
$response->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY);
$this->assertDatabaseMissing('users', ['id' => $user->id, 'email' => '-x@example.com']);
}
/**
* Test that a user can be deleted from the database.
*/
@@ -149,15 +149,6 @@ class AccountControllerTest extends ClientApiIntegrationTestCase
$response->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY);
$response->assertJsonPath('errors.0.detail', 'The email must be a valid email address.');
$response->assertJsonPath('errors.0.meta.source_field', 'email');
$response = $this->actingAs($user)->putJson('/api/client/account/email', [
'email' => '-x@example.com',
'password' => 'password',
]);
$response->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY);
$response->assertJsonPath('errors.0.meta.source_field', 'email');
$this->assertDatabaseMissing('users', ['id' => $user->id, 'email' => '-x@example.com']);
}
/**
@@ -149,21 +149,6 @@ class CreateServerSubuserTest extends ClientApiIntegrationTestCase
$response->assertJsonPath('errors.0.meta.source_field', 'email');
}
public function testSubuserWithDashPrefixedEmailCannotBeCreated()
{
[$user, $server] = $this->generateTestAccount();
$response = $this->actingAs($user)->postJson($this->link($server) . '/users', [
'email' => '-x@example.com',
'permissions' => [
Permission::ACTION_USER_CREATE,
],
]);
$response->assertStatus(Response::HTTP_UNPROCESSABLE_ENTITY);
$this->assertDatabaseMissing('users', ['email' => '-x@example.com']);
}
/**
* Test that creating a subuser when there is already an account with that email runs
* as expected and does not create a new account.