main
|
Last change
on this file since 8b014ef was 6351545, checked in by roboburr <roboburr@…>, 3 months ago |
|
tenancy: runtime Solo/Hub mode + mode-aware /admin (Phase 1)
Admin can switch live between modes in Admin -> Settings:
- solo: exactly one site (the primary/owner site), no /sites routing, leaner /admin.
- hub: main site + /sites/:slug routing (company; /gebruikers + assignment flow = Phase 2).
Switching is non-destructive (hides only, deletes nothing).
- app_settings (key/value singleton) + SettingsService (cached getTenancy/setTenancy).
- resolveSite: solo pins to the primary site + disables /sites/:slug + host mapping.
- /admin/settings (god-only) toggle; /admin dashboard rewritten, mode-aware.
Tested on the demo: solo/hub dashboard tiles, /sites routing per mode, toggle back/forth.
Co-Authored-By: Claude <noreply@…>
|
-
Property mode
set to
100644
|
|
File size:
1.0 KB
|
| Line | |
|---|
| 1 | /**
|
|---|
| 2 | * Admin: globale instellingen — nu de tenancy-modus (Solo/Hub).
|
|---|
| 3 | *
|
|---|
| 4 | * GET /admin/settings -> toon huidige modus + uitleg
|
|---|
| 5 | * POST /admin/settings -> sla modus op (god-only)
|
|---|
| 6 | *
|
|---|
| 7 | * Schakelen is niet-destructief: Solo verbergt alleen de multi-site-onderdelen
|
|---|
| 8 | * en routeert naar de primaire site; er wordt niets verwijderd.
|
|---|
| 9 | */
|
|---|
| 10 |
|
|---|
| 11 | import express from 'express';
|
|---|
| 12 | import { renderPage } from '../middleware/render.js';
|
|---|
| 13 | import { requireGod } from '../middleware/auth.js';
|
|---|
| 14 | import { getTenancy, setTenancy } from '../services/SettingsService.js';
|
|---|
| 15 |
|
|---|
| 16 | const router = express.Router();
|
|---|
| 17 |
|
|---|
| 18 | router.get('/', requireGod, (req, res) => {
|
|---|
| 19 | renderPage(req, res, 'pages/admin-settings', {
|
|---|
| 20 | pageTitle: 'Instellingen',
|
|---|
| 21 | bodyClass: 'on-admin',
|
|---|
| 22 | tenancy: getTenancy(),
|
|---|
| 23 | success: req.query.success || null,
|
|---|
| 24 | });
|
|---|
| 25 | });
|
|---|
| 26 |
|
|---|
| 27 | router.post('/', requireGod, (req, res) => {
|
|---|
| 28 | setTenancy(req.body.tenancy === 'hub' ? 'hub' : 'solo');
|
|---|
| 29 | res.redirect('/admin/settings?success=' + encodeURIComponent('Modus opgeslagen'));
|
|---|
| 30 | });
|
|---|
| 31 |
|
|---|
| 32 | export default router;
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.