diff --git a/app/Policies/ServerPolicy.php b/app/Policies/ServerPolicy.php index 92ced414e..6e49d88e7 100644 --- a/app/Policies/ServerPolicy.php +++ b/app/Policies/ServerPolicy.php @@ -60,6 +60,70 @@ class ServerPolicy return $user->permissions()->server($server)->permission('power')->exists(); } + /** + * Check if user has permission to start a server. + * + * @param Pterodactyl\Models\User $user + * @param Pterodactyl\Models\Server $server + * @return boolean + */ + public function powerStart(User $user, Server $server) + { + if ($this->isOwner($user, $server)) { + return true; + } + + return $user->permissions()->server($server)->permission('power-start')->exists(); + } + + /** + * Check if user has permission to stop a server. + * + * @param Pterodactyl\Models\User $user + * @param Pterodactyl\Models\Server $server + * @return boolean + */ + public function powerStop(User $user, Server $server) + { + if ($this->isOwner($user, $server)) { + return true; + } + + return $user->permissions()->server($server)->permission('power-stop')->exists(); + } + + /** + * Check if user has permission to restart a server. + * + * @param Pterodactyl\Models\User $user + * @param Pterodactyl\Models\Server $server + * @return boolean + */ + public function powerRestart(User $user, Server $server) + { + if ($this->isOwner($user, $server)) { + return true; + } + + return $user->permissions()->server($server)->permission('power-restart')->exists(); + } + + /** + * Check if user has permission to kill a server. + * + * @param Pterodactyl\Models\User $user + * @param Pterodactyl\Models\Server $server + * @return boolean + */ + public function powerKill(User $user, Server $server) + { + if ($this->isOwner($user, $server)) { + return true; + } + + return $user->permissions()->server($server)->permission('power-kill')->exists(); + } + /** * Check if user has permission to run a command on a server. * @@ -67,13 +131,13 @@ class ServerPolicy * @param Pterodactyl\Models\Server $server * @return boolean */ - public function command(User $user, Server $server) + public function sendCommand(User $user, Server $server) { if ($this->isOwner($user, $server)) { return true; } - return $user->permissions()->server($server)->permission('command')->exists(); + return $user->permissions()->server($server)->permission('send-command')->exists(); } /** @@ -212,13 +276,77 @@ class ServerPolicy * @param Pterodactyl\Models\Server $server * @return boolean */ - public function viewSubusers(User $user, Server $server) + public function listSubusers(User $user, Server $server) { if ($this->isOwner($user, $server)) { return true; } - return $user->permissions()->server($server)->permission('view-subusers')->exists(); + return $user->permissions()->server($server)->permission('list-subusers')->exists(); + } + + /** + * Check if user has permission to view specific subuser permissions. + * + * @param Pterodactyl\Models\User $user + * @param Pterodactyl\Models\Server $server + * @return boolean + */ + public function viewSubuser(User $user, Server $server) + { + if ($this->isOwner($user, $server)) { + return true; + } + + return $user->permissions()->server($server)->permission('view-subuser')->exists(); + } + + /** + * Check if user has permission to edit a subuser. + * + * @param Pterodactyl\Models\User $user + * @param Pterodactyl\Models\Server $server + * @return boolean + */ + public function editSubuser(User $user, Server $server) + { + if ($this->isOwner($user, $server)) { + return true; + } + + return $user->permissions()->server($server)->permission('edit-subuser')->exists(); + } + + /** + * Check if user has permission to delete a subuser. + * + * @param Pterodactyl\Models\User $user + * @param Pterodactyl\Models\Server $server + * @return boolean + */ + public function deleteSubuser(User $user, Server $server) + { + if ($this->isOwner($user, $server)) { + return true; + } + + return $user->permissions()->server($server)->permission('delete-subuser')->exists(); + } + + /** + * Check if user has permission to edit a subuser. + * + * @param Pterodactyl\Models\User $user + * @param Pterodactyl\Models\Server $server + * @return boolean + */ + public function createSubuser(User $user, Server $server) + { + if ($this->isOwner($user, $server)) { + return true; + } + + return $user->permissions()->server($server)->permission('create-subuser')->exists(); } /** diff --git a/resources/views/layouts/master.blade.php b/resources/views/layouts/master.blade.php index 9df2f5c82..470f0de82 100644 --- a/resources/views/layouts/master.blade.php +++ b/resources/views/layouts/master.blade.php @@ -194,7 +194,7 @@ {{ trans('pagination.sidebar.server_controls') }} {{ trans('pagination.sidebar.overview') }} @can('list-files', $server){{ trans('pagination.sidebar.files') }}@endcan - @can('view-subusers', $server){{ trans('pagination.sidebar.subusers') }}@endcan + @can('list-subusers', $server){{ trans('pagination.sidebar.subusers') }}@endcan @can('view-manage', $server){{ trans('pagination.sidebar.manage') }}@endcan @endif diff --git a/resources/views/server/index.blade.php b/resources/views/server/index.blade.php index e452230bd..e8e6ddcef 100644 --- a/resources/views/server/index.blade.php +++ b/resources/views/server/index.blade.php @@ -43,14 +43,12 @@