Fix wrong destination issue on create_application

This commit is contained in:
W8jonas 2026-02-26 23:15:04 -03:00
parent d29a9a2802
commit bf6b3b8c71

View file

@ -1095,6 +1095,17 @@ private function create_application(Request $request, $type)
return response()->json(['message' => 'Server has multiple destinations and you do not set destination_uuid.'], 400); return response()->json(['message' => 'Server has multiple destinations and you do not set destination_uuid.'], 400);
} }
$destination = $destinations->first(); $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 ($type === 'public') { if ($type === 'public') {
$validationRules = [ $validationRules = [
'git_repository' => ['string', 'required', new ValidGitRepositoryUrl], 'git_repository' => ['string', 'required', new ValidGitRepositoryUrl],