From 62e1883709ebafc390ce53feadfc09b0332ae295 Mon Sep 17 00:00:00 2001 From: Jonas Nascimento <39463872+W8jonas@users.noreply.github.com> Date: Sat, 25 Oct 2025 01:09:55 -0300 Subject: [PATCH] fix api - set destination_uuid when creating databases --- app/Http/Controllers/Api/DatabasesController.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/Http/Controllers/Api/DatabasesController.php b/app/Http/Controllers/Api/DatabasesController.php index 46282fddb..469b08d5c 100644 --- a/app/Http/Controllers/Api/DatabasesController.php +++ b/app/Http/Controllers/Api/DatabasesController.php @@ -1619,6 +1619,18 @@ public function create_database(Request $request, NewDatabaseTypes $type) return response()->json(['message' => 'Server has multiple destinations and you do not set destination_uuid.'], 400); } $destination = $destinations->first(); + if ($destinations->count() > 1 && $request->has('destination_uuid')) { + $destination = $destinations->where('uuid', $request->destination_uuid)->first(); + if (! $destination) { + return response()->json([ + 'message' => 'Validation failed.', + 'errors' => [ + 'destination_uuid' => 'Provided destination_uuid does not belong to the specified server.', + ], + ], 422); + } + } + if ($request->has('public_port') && $request->is_public) { if (isPublicPortAlreadyUsed($server, $request->public_port)) { return response()->json(['message' => 'Public port already used by another database.'], 400);