|
@@ -18,8 +18,7 @@ function methods($methodSchemas)
|
|
// Validate against the schema for the current request method
|
|
// Validate against the schema for the current request method
|
|
$schema = $methodSchemas[$requestMethod];
|
|
$schema = $methodSchemas[$requestMethod];
|
|
if (!$schema->validate($data)) {
|
|
if (!$schema->validate($data)) {
|
|
- http_response_code(403);
|
|
|
|
- echo json_encode(['error' => 'Invalid input']);
|
|
|
|
|
|
+ serverError('Error de validación', 'Los datos enviados no son válidos');
|
|
exit();
|
|
exit();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -97,7 +96,7 @@ function makeConnection($hostOrConnectionString, $port = null, $dbname = null, $
|
|
$db->setConnection($pdo);
|
|
$db->setConnection($pdo);
|
|
return $db;
|
|
return $db;
|
|
} catch (PDOException $e) {
|
|
} catch (PDOException $e) {
|
|
- serverError('Error de conexión', 'No se pudo conectar a la base de datos');
|
|
|
|
|
|
+ serverError('Error de conexión', 'No se pudo conectar a la base de datos: ' . $e->getMessage() . ' ' . $connectionString);
|
|
exit();
|
|
exit();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -105,3 +104,5 @@ function makeConnection($hostOrConnectionString, $port = null, $dbname = null, $
|
|
# default DB connection
|
|
# default DB connection
|
|
$db = makeConnection($_ENV['POSTGRES_HOST'], $_ENV['POSTGRES_PORT'], $_ENV['POSTGRES_DBNAME'], $_ENV['POSTGRES_USER'], $_ENV['POSTGRES_PASSWORD']);
|
|
$db = makeConnection($_ENV['POSTGRES_HOST'], $_ENV['POSTGRES_PORT'], $_ENV['POSTGRES_DBNAME'], $_ENV['POSTGRES_USER'], $_ENV['POSTGRES_PASSWORD']);
|
|
$sgi_db = makeConnection($_ENV['SGI_POSTGRES_HOST'], $_ENV['SGI_POSTGRES_PORT'], $_ENV['SGI_POSTGRES_DBNAME'], $_ENV['SGI_POSTGRES_USER'], $_ENV['SGI_POSTGRES_PASSWORD']);
|
|
$sgi_db = makeConnection($_ENV['SGI_POSTGRES_HOST'], $_ENV['SGI_POSTGRES_PORT'], $_ENV['SGI_POSTGRES_DBNAME'], $_ENV['SGI_POSTGRES_USER'], $_ENV['SGI_POSTGRES_PASSWORD']);
|
|
|
|
+if (isset($_SESSION['moodle_db']))
|
|
|
|
+ $moodle_db = makeConnection($_SESSION['moodle_db']);
|