Files
SkyMulley 04dec3dd86 bugfix: user creation now properly appears in action log (#5644)
### Description

User creation was not properly logged within the action log, neither
from sub-user invite or manual user creation. This PR adds the relevant
log and includes testing.

### Manual testing scenarios

1. Invite a user within any created server
2. Create a user in the admin
3. Verify both users appear as an action in the action log

### Questions or comments

AI was used for secondary testing, QA and code review. No code was
written by AI.

### Resolved issues:
1. [x] resolves pterodactyl/panel#5631
2026-06-01 11:55:37 -04:00

43 lines
1.3 KiB
PHP

<?php
namespace Pterodactyl\Tests\Integration\Http\Controllers\Admin\UserController;
use Pterodactyl\Models\User;
use Pterodactyl\Tests\Integration\Http\HttpTestCase;
class CreateUserTest extends HttpTestCase
{
public function testNonAdminCannotAccessEndpoint(): void
{
$this->actingAs(User::factory()->create())
->post('/admin/users/new', [
'email' => 'test@example.com',
'username' => 'testuser',
'name_first' => 'Test',
'name_last' => 'User',
])
->assertForbidden();
}
public function testCreatingAdministratorAccountIsLogged(): void
{
$admin = User::factory()->admin()->create();
$this->actingAs($admin)
->post('/admin/users/new', [
'email' => 'created.admin@example.com',
'username' => 'createdadmin',
'name_first' => 'Created',
'name_last' => 'Admin',
'root_admin' => 1,
])
->assertSessionHasNoErrors();
/** @var User $created */
$created = User::query()->where('username', 'createdadmin')->firstOrFail();
$this->assertTrue($created->root_admin);
$this->assertActivityFor('user:user.create', $admin, $created);
}
}