mirror of
				https://github.com/pelican-dev/panel.git
				synced 2025-10-27 16:26:51 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			58 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			58 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php
 | |
| 
 | |
| namespace Pterodactyl\Http\Requests\Api\Application\Users;
 | |
| 
 | |
| use Pterodactyl\Models\User;
 | |
| use Pterodactyl\Services\Acl\Api\AdminAcl;
 | |
| use Pterodactyl\Contracts\Repository\UserRepositoryInterface;
 | |
| use Pterodactyl\Exceptions\Repository\RecordNotFoundException;
 | |
| use Pterodactyl\Http\Requests\Api\Application\ApplicationApiRequest;
 | |
| 
 | |
| class GetExternalUserRequest extends ApplicationApiRequest
 | |
| {
 | |
|     /**
 | |
|      * @var User
 | |
|      */
 | |
|     private $userModel;
 | |
| 
 | |
|     /**
 | |
|      * @var string
 | |
|      */
 | |
|     protected $resource = AdminAcl::RESOURCE_USERS;
 | |
| 
 | |
|     /**
 | |
|      * @var int
 | |
|      */
 | |
|     protected $permission = AdminAcl::READ;
 | |
| 
 | |
|     /**
 | |
|      * Determine if the requested external user exists.
 | |
|      *
 | |
|      * @return bool
 | |
|      */
 | |
|     public function resourceExists(): bool
 | |
|     {
 | |
|         $repository = $this->container->make(UserRepositoryInterface::class);
 | |
| 
 | |
|         try {
 | |
|             $this->userModel = $repository->findFirstWhere([
 | |
|                 ['external_id', '=', $this->route()->parameter('external_id')],
 | |
|             ]);
 | |
|         } catch (RecordNotFoundException $exception) {
 | |
|             return false;
 | |
|         }
 | |
| 
 | |
|         return true;
 | |
|     }
 | |
| 
 | |
|     /**
 | |
|      * Return the user model for the requested external user.
 | |
|      *
 | |
|      * @return \Pterodactyl\Models\User
 | |
|      */
 | |
|     public function getUserModel(): User
 | |
|     {
 | |
|         return $this->userModel;
 | |
|     }
 | |
| }
 | 
