mirror of
				https://github.com/pelican-dev/panel.git
				synced 2025-10-31 21:46:51 +01:00 
			
		
		
		
	 93a62ac637
			
		
	
	
		93a62ac637
		
	
	
	
	
		
			
			Fixed nodes not getting a UUID during creation causing a 500 Closes https://github.com/pterodactyl/panel/issues/1930
		
			
				
	
	
		
			52 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			52 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php
 | |
| 
 | |
| namespace Pterodactyl\Services\Nodes;
 | |
| 
 | |
| use Ramsey\Uuid\Uuid;
 | |
| use Illuminate\Support\Str;
 | |
| use Pterodactyl\Models\Node;
 | |
| use Illuminate\Encryption\Encrypter;
 | |
| use Pterodactyl\Contracts\Repository\NodeRepositoryInterface;
 | |
| 
 | |
| class NodeCreationService
 | |
| {
 | |
|     /**
 | |
|      * @var \Pterodactyl\Contracts\Repository\NodeRepositoryInterface
 | |
|      */
 | |
|     protected $repository;
 | |
| 
 | |
|     /**
 | |
|      * @var \Illuminate\Encryption\Encrypter
 | |
|      */
 | |
|     private $encrypter;
 | |
| 
 | |
|     /**
 | |
|      * CreationService constructor.
 | |
|      *
 | |
|      * @param \Illuminate\Encryption\Encrypter $encrypter
 | |
|      * @param \Pterodactyl\Contracts\Repository\NodeRepositoryInterface $repository
 | |
|      */
 | |
|     public function __construct(Encrypter $encrypter, NodeRepositoryInterface $repository)
 | |
|     {
 | |
|         $this->repository = $repository;
 | |
|         $this->encrypter = $encrypter;
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * Create a new node on the panel.
 | |
|      *
 | |
|      * @param array $data
 | |
|      * @return \Pterodactyl\Models\Node
 | |
|      *
 | |
|      * @throws \Pterodactyl\Exceptions\Model\DataValidationException
 | |
|      */
 | |
|     public function handle(array $data)
 | |
|     {
 | |
|         $data['uuid'] = Uuid::uuid4()->toString();
 | |
|         $data['daemon_token'] = $this->encrypter->encrypt(Str::random(Node::DAEMON_TOKEN_LENGTH));
 | |
|         $data['daemon_token_id'] = Str::random(Node::DAEMON_TOKEN_ID_LENGTH);
 | |
| 
 | |
|         return $this->repository->create($data, true, true);
 | |
|     }
 | |
| }
 |