mirror of
https://github.com/MrUnknownDE/panel.git
synced 2026-04-20 15:23:44 +02:00
Fix up subuser API response for clients
This commit is contained in:
38
app/Transformers/Api/Client/UserTransformer.php
Normal file
38
app/Transformers/Api/Client/UserTransformer.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace Pterodactyl\Transformers\Api\Client;
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use Pterodactyl\Models\User;
|
||||
|
||||
class UserTransformer extends BaseClientTransformer
|
||||
{
|
||||
/**
|
||||
* Return the resource name for the JSONAPI output.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getResourceName(): string
|
||||
{
|
||||
return User::RESOURCE_NAME;
|
||||
}
|
||||
|
||||
/**
|
||||
* Transforms a User model into a representation that can be shown to regular
|
||||
* users of the API.
|
||||
*
|
||||
* @param \Pterodactyl\Models\User $model
|
||||
* @return array
|
||||
*/
|
||||
public function transform(User $model)
|
||||
{
|
||||
return [
|
||||
'uuid' => $model->uuid,
|
||||
'username' => $model->username,
|
||||
'email' => $model->email,
|
||||
'image' => 'https://gravatar.com/avatar/' . md5(Str::lower($model->email)),
|
||||
'2fa_enabled' => $model->use_totp,
|
||||
'created_at' => $model->created_at->toIso8601String(),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user