v0.9.26 added a admin tools
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user