user: yeet remaining name_* fields, again...

This commit is contained in:
Matthew Penner 2021-08-02 22:17:11 -06:00
parent 4d77d486ec
commit d2864410ed
5 changed files with 10 additions and 36 deletions

View file

@ -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);

View file

@ -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
*/

View file

@ -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,

View file

@ -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']);

View file

@ -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,
],
]);