asdsd
All checks were successful
Deploy / deploy-staging (push) Successful in 5s
Deploy / deploy-production (push) Has been skipped

This commit is contained in:
2026-04-11 02:31:23 +02:00
parent dc4abe9563
commit c15c90bf6d
3 changed files with 309 additions and 2 deletions

View File

@@ -38,7 +38,7 @@ $publicPaths = [
'auth/me',
'module/pi_control/terminal_info',
];
$requiresGlobalAuth = in_array($uriPath, ['settings', 'users', 'modules', 'modules/install', 'debug'], true)
$requiresGlobalAuth = in_array($uriPath, ['settings', 'users', 'modules', 'modules/install', 'debug', 'exports/database.sql'], true)
|| str_starts_with($uriPath, 'modules/setup/');
if (defined('APP_AUTH_ENABLED') && APP_AUTH_ENABLED && $requiresGlobalAuth && !in_array($uriPath, $publicPaths, true)) {
$user = auth_user();
@@ -76,6 +76,23 @@ if ($uriPath === 'auth/me') {
exit;
}
if ($uriPath === 'exports/database.sql') {
require_admin();
$pdo = app()->basePdo() ?: app()->pdo();
if (!$pdo instanceof PDO) {
http_response_code(500);
exit('Keine Datenbankverbindung fuer den Export verfuegbar.');
}
$filename = 'nexus-export-' . gmdate('Ymd-His') . '.sql';
$sql = (new \App\SqlDataExporter())->export($pdo, 'nexus');
header('Content-Type: application/sql; charset=utf-8');
header('Content-Disposition: attachment; filename="' . $filename . '"');
header('X-Content-Type-Options: nosniff');
echo $sql;
exit;
}
if (preg_match('~^api/module-auth/([a-zA-Z0-9_-]+)$~', $uriPath, $moduleAuthMatches)) {
$moduleName = $moduleAuthMatches[1];
$moduleMeta = app()->modules()->get($moduleName);