--- // Password-protected admin page for viewing consent logs import { db, ConsentLog, desc } from 'astro:db'; // Simple password protection (in production, use proper auth) const ADMIN_PASSWORD = Astro.env.ADMIN_PASSWORD || 'changeme'; let logs = []; let isAuthenticated = false; let error = ''; if (Astro.request.method === 'POST') { const formData = await Astro.request.formData(); const password = formData.get('password'); if (password === ADMIN_PASSWORD) { isAuthenticated = true; try { logs = await db.select().from(ConsentLog).orderBy(desc(ConsentLog.timestamp)).limit(100); } catch (err) { error = 'Failed to load consent logs. Make sure database is initialized.'; console.error(err); } } else { error = 'Invalid password'; } } ---
Default password: changeme (change in .env)
| Date/Time | Locale | Session ID | Essential | Analytics | Marketing | Policy Ver | IP Hash | Action |
|---|---|---|---|---|---|---|---|---|
| No consent logs found. Make sure the website has received consent. | ||||||||
| {new Date(log.timestamp).toLocaleString('en-GB')} | {log.locale.toUpperCase()} | {log.sessionId} | {log.essential ? 'Yes' : 'No'} | {log.analytics ? ( ✓ ) : ( ✗ )} | {log.marketing ? ( ✓ ) : ( ✗ )} | {log.policyVersion} | {log.ipHash} | |