2022-10-24 15:44:16 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Database\Factories;
|
|
|
|
|
|
|
|
use Ramsey\Uuid\Uuid;
|
|
|
|
use Pterodactyl\Models\User;
|
|
|
|
use Pterodactyl\Models\SecurityKey;
|
|
|
|
use Webauthn\TrustPath\EmptyTrustPath;
|
|
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
|
|
|
|
|
|
class SecurityKeyFactory extends Factory
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* The name of the factory's corresponding model.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected $model = SecurityKey::class;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Define the model's default state.
|
|
|
|
*/
|
|
|
|
public function definition(): array
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
'uuid' => Uuid::uuid4()->toString(),
|
2022-10-31 19:20:06 +00:00
|
|
|
'user_id' => User::factory(),
|
2022-10-24 15:44:16 +00:00
|
|
|
'name' => $this->faker->word,
|
|
|
|
'type' => 'public-key',
|
|
|
|
'transports' => [],
|
|
|
|
'attestation_type' => 'none',
|
|
|
|
'trust_path' => new EmptyTrustPath(),
|
2022-10-31 19:20:06 +00:00
|
|
|
'user_handle' => function (array $attributes) {
|
|
|
|
return User::find($attributes['user_id'])->uuid;
|
|
|
|
},
|
2022-10-24 15:44:16 +00:00
|
|
|
'counter' => 0,
|
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|