diff --git a/app/Http/Controllers/Api/Application/Users/UserController.php b/app/Http/Controllers/Api/Application/Users/UserController.php index 789b8bf77..5fe2ca75a 100644 --- a/app/Http/Controllers/Api/Application/Users/UserController.php +++ b/app/Http/Controllers/Api/Application/Users/UserController.php @@ -58,7 +58,7 @@ class UserController extends ApplicationApiController } $users = QueryBuilder::for(User::query()) - ->allowedFilters(['id', 'uuid', 'username', 'email', 'first_name', 'last_name', 'external_id']) + ->allowedFilters(['id', 'uuid', 'username', 'email', 'external_id']) ->allowedSorts(['id', 'uuid', 'username', 'email', 'admin_role_id']) ->paginate($perPage); diff --git a/app/Models/User.php b/app/Models/User.php index b035d4a6d..707635e88 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -23,8 +23,6 @@ use Pterodactyl\Notifications\SendPasswordReset as ResetPasswordNotification; * @property string $uuid * @property string $username * @property string $email - * @property string|null $name_first - * @property string|null $name_last * @property string $password * @property string|null $remember_token * @property string $language @@ -195,17 +193,7 @@ class User extends Model implements } /** - * Return a concatenated result for the accounts full name. - * - * @return string - */ - public function getNameAttribute() - { - return trim($this->name_first . ' ' . $this->name_last); - } - - /** - * Get's the avatar url for the user. + * Gets the avatar url for the user. * * @return string */ @@ -215,7 +203,7 @@ class User extends Model implements } /** - * Get's the name of the role assigned to a user. + * Gets the name of the role assigned to a user. * * @return string|null */ diff --git a/tests/Integration/Api/Application/Users/ExternalUserControllerTest.php b/tests/Integration/Api/Application/Users/ExternalUserControllerTest.php index 983710b16..f634931c1 100644 --- a/tests/Integration/Api/Application/Users/ExternalUserControllerTest.php +++ b/tests/Integration/Api/Application/Users/ExternalUserControllerTest.php @@ -21,7 +21,7 @@ class ExternalUserControllerTest extends ApplicationApiIntegrationTestCase $response->assertJsonStructure([ 'object', 'attributes' => [ - 'id', 'external_id', 'uuid', 'username', 'email', 'first_name', 'last_name', + 'id', 'external_id', 'uuid', 'username', 'email', 'language', 'root_admin', '2fa', 'created_at', 'updated_at', ], ]); @@ -34,8 +34,6 @@ class ExternalUserControllerTest extends ApplicationApiIntegrationTestCase 'uuid' => $user->uuid, 'username' => $user->username, 'email' => $user->email, - 'first_name' => $user->name_first, - 'last_name' => $user->name_last, 'language' => $user->language, 'root_admin' => (bool) $user->root_admin, '2fa' => (bool) $user->totp_enabled, diff --git a/tests/Integration/Api/Application/Users/UserControllerTest.php b/tests/Integration/Api/Application/Users/UserControllerTest.php index d35b73026..6fe431148 100644 --- a/tests/Integration/Api/Application/Users/UserControllerTest.php +++ b/tests/Integration/Api/Application/Users/UserControllerTest.php @@ -24,8 +24,8 @@ class UserControllerTest extends ApplicationApiIntegrationTestCase $response->assertJsonStructure([ 'object', 'data' => [ - ['object', 'attributes' => ['id', 'external_id', 'uuid', 'username', 'email', 'first_name', 'last_name', 'language', 'root_admin', '2fa', 'avatar_url', 'role_name', 'created_at', 'updated_at']], - ['object', 'attributes' => ['id', 'external_id', 'uuid', 'username', 'email', 'first_name', 'last_name', 'language', 'root_admin', '2fa', 'avatar_url', 'role_name', 'created_at', 'updated_at']], + ['object', 'attributes' => ['id', 'external_id', 'uuid', 'username', 'email', 'language', 'root_admin', '2fa', 'avatar_url', 'role_name', 'created_at', 'updated_at']], + ['object', 'attributes' => ['id', 'external_id', 'uuid', 'username', 'email', 'language', 'root_admin', '2fa', 'avatar_url', 'role_name', 'created_at', 'updated_at']], ], 'meta' => ['pagination' => ['total', 'count', 'per_page', 'current_page', 'total_pages', 'links']], ]); @@ -53,8 +53,6 @@ class UserControllerTest extends ApplicationApiIntegrationTestCase 'uuid' => $this->getApiUser()->uuid, 'username' => $this->getApiUser()->username, 'email' => $this->getApiUser()->email, - 'first_name' => $this->getApiUser()->name_first, - 'last_name' => $this->getApiUser()->name_last, 'language' => $this->getApiUser()->language, 'root_admin' => (bool) $this->getApiUser()->root_admin, '2fa' => (bool) $this->getApiUser()->totp_enabled, @@ -72,8 +70,6 @@ class UserControllerTest extends ApplicationApiIntegrationTestCase 'uuid' => $user->uuid, 'username' => $user->username, 'email' => $user->email, - 'first_name' => $user->name_first, - 'last_name' => $user->name_last, 'language' => $user->language, 'root_admin' => (bool) $user->root_admin, '2fa' => (bool) $user->totp_enabled, @@ -97,7 +93,7 @@ class UserControllerTest extends ApplicationApiIntegrationTestCase $response->assertJsonCount(2); $response->assertJsonStructure([ 'object', - 'attributes' => ['id', 'external_id', 'uuid', 'username', 'email', 'first_name', 'last_name', 'language', 'root_admin', '2fa', 'created_at', 'updated_at'], + 'attributes' => ['id', 'external_id', 'uuid', 'username', 'email', 'language', 'root_admin', '2fa', 'created_at', 'updated_at'], ]); $response->assertJson([ @@ -108,8 +104,6 @@ class UserControllerTest extends ApplicationApiIntegrationTestCase 'uuid' => $user->uuid, 'username' => $user->username, 'email' => $user->email, - 'first_name' => $user->name_first, - 'last_name' => $user->name_last, 'language' => $user->language, 'root_admin' => (bool) $user->root_admin, '2fa' => (bool) $user->totp_enabled, @@ -133,7 +127,7 @@ class UserControllerTest extends ApplicationApiIntegrationTestCase $response->assertJsonStructure([ 'object', 'attributes' => [ - 'id', 'external_id', 'uuid', 'username', 'email', 'first_name', 'last_name', 'language', 'root_admin', '2fa', 'created_at', 'updated_at', + 'id', 'external_id', 'uuid', 'username', 'email', 'language', 'root_admin', '2fa', 'created_at', 'updated_at', 'relationships' => ['servers' => ['object', 'data' => [['object', 'attributes' => []]]]], ], ]); @@ -226,15 +220,13 @@ class UserControllerTest extends ApplicationApiIntegrationTestCase $response = $this->postJson('/api/application/users', [ 'username' => 'testuser', 'email' => 'test@example.com', - 'first_name' => 'Test', - 'last_name' => 'User', ]); $response->assertStatus(Response::HTTP_CREATED); $response->assertJsonCount(3); $response->assertJsonStructure([ 'object', - 'attributes' => ['id', 'external_id', 'uuid', 'username', 'email', 'first_name', 'last_name', 'language', 'root_admin', '2fa', 'created_at', 'updated_at'], + 'attributes' => ['id', 'external_id', 'uuid', 'username', 'email', 'language', 'root_admin', '2fa', 'created_at', 'updated_at'], 'meta' => ['resource'], ]); @@ -260,14 +252,12 @@ class UserControllerTest extends ApplicationApiIntegrationTestCase $response = $this->patchJson('/api/application/users/' . $user->id, [ 'username' => 'new.test.name', 'email' => 'new@emailtest.com', - 'first_name' => $user->name_first, - 'last_name' => $user->name_last, ]); $response->assertStatus(Response::HTTP_OK); $response->assertJsonCount(2); $response->assertJsonStructure([ 'object', - 'attributes' => ['id', 'external_id', 'uuid', 'username', 'email', 'first_name', 'last_name', 'language', 'root_admin', '2fa', 'created_at', 'updated_at'], + 'attributes' => ['id', 'external_id', 'uuid', 'username', 'email', 'language', 'root_admin', '2fa', 'created_at', 'updated_at'], ]); $this->assertDatabaseHas('users', ['username' => 'new.test.name', 'email' => 'new@emailtest.com']); diff --git a/tests/Integration/Api/Client/AccountControllerTest.php b/tests/Integration/Api/Client/AccountControllerTest.php index 3ed689ef9..255a413f1 100644 --- a/tests/Integration/Api/Client/AccountControllerTest.php +++ b/tests/Integration/Api/Client/AccountControllerTest.php @@ -26,8 +26,6 @@ class AccountControllerTest extends ClientApiIntegrationTestCase 'admin' => false, 'username' => $user->username, 'email' => $user->email, - 'first_name' => $user->name_first, - 'last_name' => $user->name_last, 'language' => $user->language, ], ]);