This commit is contained in:
2026-02-02 19:12:40 +01:00
parent c6421049c8
commit 952c353118
17 changed files with 982 additions and 513 deletions

View File

@@ -3,15 +3,36 @@
const { hasRole } = require('../helpers/utils');
const { requireAuth } = require('../middleware/auth');
const { generateCheckinCheckoutQRPDF } = require('../services/pdf-service');
const { db } = require('../database');
// Routes registrieren
function registerDashboardRoutes(app) {
// Check-in Root URL abrufen (öffentlich zugänglich für Konfiguration)
app.get('/api/checkin-root-url', (req, res) => {
db.get('SELECT checkin_root_url FROM system_options WHERE id = 1', (err, options) => {
if (err) {
return res.status(500).json({ error: 'Fehler beim Laden der Root URL' });
}
res.json({
root_url: options && options.checkin_root_url ? options.checkin_root_url : null
});
});
});
// QR-Code-PDF (Check-in/Check-out) nur für eingeloggte Nutzer mit Mitarbeiter-Rolle
app.get('/api/dashboard/qr-pdf', requireAuth, (req, res) => {
// Interne URLs
app.get('/api/dashboard/qr-pdf/internal', requireAuth, (req, res) => {
if (!hasRole(req, 'mitarbeiter')) {
return res.status(403).send('Zugriff verweigert');
}
generateCheckinCheckoutQRPDF(req, res);
generateCheckinCheckoutQRPDF(req, res, 'internal');
});
// Externe URLs
app.get('/api/dashboard/qr-pdf/external', requireAuth, (req, res) => {
if (!hasRole(req, 'mitarbeiter')) {
return res.status(403).send('Zugriff verweigert');
}
generateCheckinCheckoutQRPDF(req, res, 'external');
});
// Dashboard für Mitarbeiter