|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace Pterodactyl\Repositories; |
| 4 | + |
| 5 | +use DB; |
| 6 | +use Validator; |
| 7 | + |
| 8 | +use Pterodactyl\Models; |
| 9 | +use Pterodactyl\Services\UuidService; |
| 10 | + |
| 11 | +use Pterodactyl\Exceptions\DisplayValidationException; |
| 12 | +use Pterodactyl\Exceptions\DisplayException; |
| 13 | + |
| 14 | +class UserRepository |
| 15 | +{ |
| 16 | + |
| 17 | + /** |
| 18 | + * Allowed permissions and their related daemon permission. |
| 19 | + * @var array |
| 20 | + */ |
| 21 | + protected $permissions = [ |
| 22 | + // Power Permissions |
| 23 | + 'power-start' => 's:power:start', |
| 24 | + 'power-stop' => 's:power:stop', |
| 25 | + 'power-restart' => 's:power:restart', |
| 26 | + 'power-kill' => 's:power:kill', |
| 27 | + |
| 28 | + // Commands |
| 29 | + 'send-command' => 's:command', |
| 30 | + |
| 31 | + // File Manager |
| 32 | + 'list-files' => 's:files:get', |
| 33 | + 'edit-file' => 's:files:read', |
| 34 | + 'save-file' => 's:files:post', |
| 35 | + 'create-file' => 's:files:post', |
| 36 | + 'download-file' => null, |
| 37 | + 'upload-file' => 's:files:upload', |
| 38 | + 'delete-file' => 's:files:delete', |
| 39 | + |
| 40 | + // Subusers |
| 41 | + 'list-subusers' => null, |
| 42 | + 'view-subuser' => null, |
| 43 | + 'edit-subuser' => null, |
| 44 | + 'create-subuser' => null, |
| 45 | + 'delete-subuser' => null, |
| 46 | + |
| 47 | + // Management |
| 48 | + 'set-connection' => null, |
| 49 | + 'view-sftp' => null, |
| 50 | + 'reset-sftp' => 's:set-password' |
| 51 | + ]; |
| 52 | + |
| 53 | + public function __construct() |
| 54 | + { |
| 55 | + // |
| 56 | + } |
| 57 | + |
| 58 | + /** |
| 59 | + * Updates permissions for a given subuser. |
| 60 | + * @param integer $id The ID of the subuser row in MySQL. (Not the user ID) |
| 61 | + * @param array $data |
| 62 | + * @throws DisplayValidationException |
| 63 | + * @throws DisplayException |
| 64 | + * @return void |
| 65 | + */ |
| 66 | + public function update($id, array $data) |
| 67 | + { |
| 68 | + $validator = Validator::make($data, [ |
| 69 | + 'permissions' => 'required|array' |
| 70 | + ]); |
| 71 | + |
| 72 | + if ($validator->fails()) { |
| 73 | + throw new DisplayValidationException(json_encode($validator->all())); |
| 74 | + } |
| 75 | + |
| 76 | + // @TODO the thing. |
| 77 | + |
| 78 | + } |
0 commit comments