Fix exception thrown due to lack of pre-validation on the model.
closes #1158
This commit is contained in:
parent
fae5acf99f
commit
6967b9ba12
5 changed files with 29 additions and 9 deletions
|
@ -8,6 +8,7 @@ This project follows [Semantic Versioning](http://semver.org) guidelines.
|
||||||
* Fixes an issue with the sidebar logo not working correctly in some browsers due to the CSS being assigned.
|
* Fixes an issue with the sidebar logo not working correctly in some browsers due to the CSS being assigned.
|
||||||
* Fixes a bunch of typos through the code base.
|
* Fixes a bunch of typos through the code base.
|
||||||
* Fixes a bug when attempting to load the dropdown menu for server owner in some cases.
|
* Fixes a bug when attempting to load the dropdown menu for server owner in some cases.
|
||||||
|
* Fixes an exception thrown when the database connection address was not filled out correctly while adding a database to a server.
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
* Added a new client API endpoint for gathering the utilization stats for servers including disk, cpu, and memory. `GET /api/client/servers/<id>/utilization`
|
* Added a new client API endpoint for gathering the utilization stats for servers including disk, cpu, and memory. `GET /api/client/servers/<id>/utilization`
|
||||||
|
|
|
@ -35,6 +35,7 @@ use Pterodactyl\Contracts\Repository\ServerRepositoryInterface;
|
||||||
use Pterodactyl\Contracts\Repository\DatabaseRepositoryInterface;
|
use Pterodactyl\Contracts\Repository\DatabaseRepositoryInterface;
|
||||||
use Pterodactyl\Contracts\Repository\LocationRepositoryInterface;
|
use Pterodactyl\Contracts\Repository\LocationRepositoryInterface;
|
||||||
use Pterodactyl\Contracts\Repository\AllocationRepositoryInterface;
|
use Pterodactyl\Contracts\Repository\AllocationRepositoryInterface;
|
||||||
|
use Pterodactyl\Http\Requests\Admin\Servers\Databases\StoreServerDatabaseRequest;
|
||||||
|
|
||||||
class ServersController extends Controller
|
class ServersController extends Controller
|
||||||
{
|
{
|
||||||
|
@ -558,15 +559,13 @@ class ServersController extends Controller
|
||||||
/**
|
/**
|
||||||
* Creates a new database assigned to a specific server.
|
* Creates a new database assigned to a specific server.
|
||||||
*
|
*
|
||||||
* @param \Illuminate\Http\Request $request
|
* @param \Pterodactyl\Http\Requests\Admin\Servers\Databases\StoreServerDatabaseRequest $request
|
||||||
* @param int $server
|
* @param int $server
|
||||||
* @return \Illuminate\Http\RedirectResponse
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
*
|
*
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
* @throws \Pterodactyl\Exceptions\DisplayException
|
|
||||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
|
||||||
*/
|
*/
|
||||||
public function newDatabase(Request $request, $server)
|
public function newDatabase(StoreServerDatabaseRequest $request, $server)
|
||||||
{
|
{
|
||||||
$this->databaseManagementService->create($server, [
|
$this->databaseManagementService->create($server, [
|
||||||
'database' => $request->input('database'),
|
'database' => $request->input('database'),
|
||||||
|
|
|
@ -104,8 +104,6 @@ class DatabaseController extends ApplicationApiController
|
||||||
* @return \Illuminate\Http\JsonResponse
|
* @return \Illuminate\Http\JsonResponse
|
||||||
*
|
*
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
* @throws \Pterodactyl\Exceptions\DisplayException
|
|
||||||
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
|
||||||
*/
|
*/
|
||||||
public function store(StoreServerDatabaseRequest $request): JsonResponse
|
public function store(StoreServerDatabaseRequest $request): JsonResponse
|
||||||
{
|
{
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Pterodactyl\Http\Requests\Admin\Servers\Databases;
|
||||||
|
|
||||||
|
use Pterodactyl\Http\Requests\Admin\AdminFormRequest;
|
||||||
|
|
||||||
|
class StoreServerDatabaseRequest extends AdminFormRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Validation rules for database creation.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function rules(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'database' => 'required|string|min:1|max:24',
|
||||||
|
'remote' => 'required|string|regex:/^[0-9%.]{1,15}$/',
|
||||||
|
'database_host_id' => 'required|integer|exists:database_hosts,id',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
|
@ -26,7 +26,7 @@ class StoreServerDatabaseRequest extends ApplicationApiRequest
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'database' => 'required|string|min:1|max:24',
|
'database' => 'required|string|min:1|max:24',
|
||||||
'remote' => 'required|string|min:1',
|
'remote' => 'required|string|regex:/^[0-9%.]{1,15}$/',
|
||||||
'host' => 'required|integer|exists:database_hosts,id',
|
'host' => 'required|integer|exists:database_hosts,id',
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue