Fix event creation errors

- Fix req.user undefined error by using req.admin from middleware
- Return proper ISO date strings in event creation response
- Include created_at in response for frontend navigation

This fixes the 500 error when creating events and ensures the frontend
receives the expected data format for navigation.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-07-07 14:17:14 +02:00
parent fece843505
commit 53704ec92e
+3 -2
View File
@@ -85,7 +85,7 @@ router.post('/', adminAuth, [
await logActivity('event_created',
{ event_type, expires_at },
eventId,
{ type: 'admin', id: req.user.id, name: req.user.username }
{ type: 'admin', id: req.admin.id, name: req.admin.username }
);
// Queue creation email
@@ -108,7 +108,8 @@ router.post('/', adminAuth, [
event_name,
event_type,
share_link: shareLink,
expires_at
expires_at: expires_at.toISOString(),
created_at: new Date().toISOString()
});
} catch (error) {
console.error('Error creating event:', error);