v0.9.26 added a admin tools

This commit is contained in:
2026-03-15 16:36:01 -04:00
parent 53d665cc6f
commit 7bc0d26cdd
17 changed files with 872 additions and 96 deletions

View File

@@ -134,4 +134,34 @@ router.post('/reset', authMiddleware, adminMiddleware, (req, res) => {
res.json({ success: true });
});
// ── Registration code ─────────────────────────────────────────────────────────
// Valid codes — in production these would be stored/validated server-side
const VALID_CODES = {
'JAMA-FULL-2024': { branding: true, groupManager: true },
'JAMA-BRAND-2024': { branding: true, groupManager: false },
};
router.post('/register', authMiddleware, adminMiddleware, (req, res) => {
const { code } = req.body;
const db = getDb();
const upd = db.prepare("INSERT INTO settings (key, value) VALUES (?, ?) ON CONFLICT(key) DO UPDATE SET value = ?, updated_at = datetime('now')");
if (!code?.trim()) {
// Clear registration
upd.run('registration_code', '', '');
upd.run('feature_branding', 'false', 'false');
upd.run('feature_group_manager', 'false', 'false');
return res.json({ success: true, features: { branding: false, groupManager: false } });
}
const match = VALID_CODES[code.trim().toUpperCase()];
if (!match) return res.status(400).json({ error: 'Invalid registration code' });
upd.run('registration_code', code.trim(), code.trim());
upd.run('feature_branding', match.branding ? 'true' : 'false', match.branding ? 'true' : 'false');
upd.run('feature_group_manager', match.groupManager ? 'true' : 'false', match.groupManager ? 'true' : 'false');
res.json({ success: true, features: { branding: match.branding, groupManager: match.groupManager } });
});
module.exports = router;