An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 360+ one-click services on your own servers.
PHP coolifydatabasesdeploymentdockerdocker-composeinertiajslaravelmariadbmysqlnextjsnodejsphppostgresredisself-hostedself-hostingserverstatic-sitesveltesvelte5
fix(api): Add back validateDataApplications (#5539)
Andrew Nagy61c689d80785
diff --git a/app/Http/Controllers/Api/ApplicationsController.php b/app/Http/Controllers/Api/ApplicationsController.phpindex 0044e86b45..45968b6c6f 100644--- a/app/Http/Controllers/Api/ApplicationsController.php+++ b/app/Http/Controllers/Api/ApplicationsController.php@@ -3006,73 +3006,73 @@ class ApplicationsController extends Controller// ]);// }- // private function validateDataApplications(Request $request, Server $server)- // {- // $teamId = getTeamIdFromToken();-- // // Validate ports_mappings- // if ($request->has('ports_mappings')) {- // $ports = [];- // foreach (explode(',', $request->ports_mappings) as $portMapping) {- // $port = explode(':', $portMapping);- // if (in_array($port[0], $ports)) {- // return response()->json([- // 'message' => 'Validation failed.',- // 'errors' => [- // 'ports_mappings' => 'The first number before : should be unique between mappings.',- // ],- // ], 422);- // }- // $ports[] = $port[0];- // }- // }- // // Validate custom_labels- // if ($request->has('custom_labels')) {- // if (! isBase64Encoded($request->custom_labels)) {- // return response()->json([- // 'message' => 'Validation failed.',- // 'errors' => [- // 'custom_labels' => 'The custom_labels should be base64 encoded.',- // ],- // ], 422);- // }- // $customLabels = base64_decode($request->custom_labels);- // if (mb_detect_encoding($customLabels, 'ASCII', true) === false) {- // return response()->json([- // 'message' => 'Validation failed.',- // 'errors' => [- // 'custom_labels' => 'The custom_labels should be base64 encoded.',- // ],- // ], 422);- // }- // }- // if ($request->has('domains') && $server->isProxyShouldRun()) {- // $uuid = $request->uuid;- // $fqdn = $request->domains;- // $fqdn = str($fqdn)->replaceEnd(',', '')->trim();- // $fqdn = str($fqdn)->replaceStart(',', '')->trim();- // $errors = [];- // $fqdn = str($fqdn)->trim()->explode(',')->map(function ($domain) use (&$errors) {- // if (filter_var($domain, FILTER_VALIDATE_URL) === false) {- // $errors[] = 'Invalid domain: '.$domain;- // }-- // return str($domain)->trim()->lower();- // });- // if (count($errors) > 0) {- // return response()->json([- // 'message' => 'Validation failed.',- // 'errors' => $errors,- // ], 422);- // }- // if (checkIfDomainIsAlreadyUsed($fqdn, $teamId, $uuid)) {- // return response()->json([- // 'message' => 'Validation failed.',- // 'errors' => [- // 'domains' => 'One of the domain is already used.',- // ],- // ], 422);- // }- // }- // }+ private function validateDataApplications(Request $request, Server $server)+ {+ $teamId = getTeamIdFromToken();++ // Validate ports_mappings+ if ($request->has('ports_mappings')) {+ $ports = [];+ foreach (explode(',', $request->ports_mappings) as $portMapping) {+ $port = explode(':', $portMapping);+ if (in_array($port[0], $ports)) {+ return response()->json([+ 'message' => 'Validation failed.',+ 'errors' => [+ 'ports_mappings' => 'The first number before : should be unique between mappings.',+ ],+ ], 422);+ }+ $ports[] = $port[0];+ }+ }+ // Validate custom_labels+ if ($request->has('custom_labels')) {+ if (! isBase64Encoded($request->custom_labels)) {+ return response()->json([+ 'message' => 'Validation failed.',+ 'errors' => [+ 'custom_labels' => 'The custom_labels should be base64 encoded.',+ ],+ ], 422);+ }+ $customLabels = base64_decode($request->custom_labels);+ if (mb_detect_encoding($customLabels, 'ASCII', true) === false) {+ return response()->json([+ 'message' => 'Validation failed.',+ 'errors' => [+ 'custom_labels' => 'The custom_labels should be base64 encoded.',+ ],+ ], 422);+ }+ }+ if ($request->has('domains') && $server->isProxyShouldRun()) {+ $uuid = $request->uuid;+ $fqdn = $request->domains;+ $fqdn = str($fqdn)->replaceEnd(',', '')->trim();+ $fqdn = str($fqdn)->replaceStart(',', '')->trim();+ $errors = [];+ $fqdn = str($fqdn)->trim()->explode(',')->map(function ($domain) use (&$errors) {+ if (filter_var($domain, FILTER_VALIDATE_URL) === false) {+ $errors[] = 'Invalid domain: '.$domain;+ }++ return str($domain)->trim()->lower();+ });+ if (count($errors) > 0) {+ return response()->json([+ 'message' => 'Validation failed.',+ 'errors' => $errors,+ ], 422);+ }+ if (checkIfDomainIsAlreadyUsed($fqdn, $teamId, $uuid)) {+ return response()->json([+ 'message' => 'Validation failed.',+ 'errors' => [+ 'domains' => 'One of the domain is already used.',+ ],+ ], 422);+ }+ }+ }}