mirror of
https://github.com/MrUnknownDE/panel.git
synced 2026-04-17 22:03:44 +02:00
Add base routes for managing servers as a client
This commit is contained in:
19
app/Http/Requests/Api/Client/ClientApiRequest.php
Normal file
19
app/Http/Requests/Api/Client/ClientApiRequest.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace Pterodactyl\Http\Requests\Api\Client;
|
||||
|
||||
use Pterodactyl\Http\Requests\Api\Application\ApplicationApiRequest;
|
||||
|
||||
abstract class ClientApiRequest extends ApplicationApiRequest
|
||||
{
|
||||
/**
|
||||
* Determine if the current user is authorized to perform
|
||||
* the requested action aganist the API.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
14
app/Http/Requests/Api/Client/GetServersRequest.php
Normal file
14
app/Http/Requests/Api/Client/GetServersRequest.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace Pterodactyl\Http\Requests\Api\Client;
|
||||
|
||||
class GetServersRequest extends ClientApiRequest
|
||||
{
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
31
app/Http/Requests/Api/Client/Servers/GetServerRequest.php
Normal file
31
app/Http/Requests/Api/Client/Servers/GetServerRequest.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace Pterodactyl\Http\Requests\Api\Client\Servers;
|
||||
|
||||
use Pterodactyl\Models\Server;
|
||||
use Pterodactyl\Http\Requests\Api\Client\ClientApiRequest;
|
||||
|
||||
class GetServerRequest extends ClientApiRequest
|
||||
{
|
||||
/**
|
||||
* Determine if a client has permission to view this server on the API. This
|
||||
* should never be false since this would be checking the same permission as
|
||||
* resourceExists().
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the user should even know that this server exists.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function resourceExists(): bool
|
||||
{
|
||||
return $this->user()->can('view-server', $this->getModel(Server::class));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user