Add initial go at user created databases for servers, still needs cleaning
This commit is contained in:
parent
87b96bdfc8
commit
07893effa3
11 changed files with 314 additions and 25 deletions
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
|
||||
namespace Pterodactyl\Http\Requests\Server\Database;
|
||||
|
||||
use Pterodactyl\Http\Requests\Server\ServerFormRequest;
|
||||
|
||||
class StoreServerDatabaseRequest extends ServerFormRequest
|
||||
{
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
if (! parent::authorize()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return config('pterodactyl.client_features.databases.enabled');
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the user permission to validate this request aganist.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function permission(): string
|
||||
{
|
||||
return 'create-database';
|
||||
}
|
||||
|
||||
/**
|
||||
* Rules to validate this request aganist.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'database' => 'required|string|min:1',
|
||||
'remote' => 'required|string|regex:/^[0-9%.]{1,15}$/',
|
||||
];
|
||||
}
|
||||
}
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Pterodactyl\Http\Requests\Server;
|
||||
|
||||
use Pterodactyl\Models\Server;
|
||||
use Pterodactyl\Http\Requests\FrontendUserFormRequest;
|
||||
|
||||
abstract class ServerFormRequest extends FrontendUserFormRequest
|
||||
|
@ -24,6 +25,11 @@ abstract class ServerFormRequest extends FrontendUserFormRequest
|
|||
return false;
|
||||
}
|
||||
|
||||
return $this->user()->can($this->permission(), $this->attributes->get('server'));
|
||||
return $this->user()->can($this->permission(), $this->getServer());
|
||||
}
|
||||
|
||||
public function getServer(): Server
|
||||
{
|
||||
return $this->attributes->get('server');
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue