chore(customer-portal): align flag-gate comments with new dual-enforcement

This commit is contained in:
Luca
2026-05-11 19:38:18 +02:00
parent 2a7ae0702d
commit c0c6b4c0e8
2 changed files with 23 additions and 13 deletions
+14 -7
View File
@@ -568,13 +568,20 @@ app.use('/api/admin/photo-export', require('./src/routes/adminPhotoExport'));
app.use('/api/admin/css-templates', require('./src/routes/adminCssTemplates')); app.use('/api/admin/css-templates', require('./src/routes/adminCssTemplates'));
app.use('/api/admin/events', require('./src/routes/adminEventRename')); app.use('/api/admin/events', require('./src/routes/adminEventRename'));
app.use('/api/admin/users', require('./src/routes/adminUsers')); app.use('/api/admin/users', require('./src/routes/adminUsers'));
// Customer portal (#354). When the `customerPortal` feature flag is // Customer portal (#354). The customerPortal feature flag is enforced
// OFF, both the admin-facing /api/admin/customers/* surface AND the // in TWO places:
// customer-facing /api/customer/* surface return 410 Gone — turning // 1. Frontend: RequireFeature guards + AdminSidebar visibility
// the toggle off in Settings → Features cleanly kills the feature // (handles navigation cleanly when an admin is using the app).
// everywhere, not just in the UI. The frontend RequireFeature guard // 2. Backend: the requireCustomerPortalEnabled middleware below.
// + AdminSidebar visibility still apply for navigation, but a stale // Belt-and-braces — a stale tab, a saved bookmark, or any
// tab or third-party API client can't bypass the gate. // third-party API client trying to hit /api/customer/* or
// /api/admin/customers/* gets a 410 Gone the moment the toggle
// is flipped off. Includes /api/customer/auth/login: flag off
// = nobody can log in until the admin re-enables, including
// already-issued customers (their sessions still have valid
// JWTs but every API call returns 410 → frontend boots them
// out). PR #458 deliberate departure from the prior design
// that left login alive when the rest of the surface was off.
const { const {
requireCustomerPortalEnabled, requireCustomerPortalEnabled,
requireCustomerPortalEnabledAdmin, requireCustomerPortalEnabledAdmin,
+9 -6
View File
@@ -48,12 +48,15 @@ const TOKEN_TTL_SECONDS = 24 * 60 * 60; // mirrors admin tokens
// ---- login ------------------------------------------------------------- // ---- login -------------------------------------------------------------
// The customerPortal feature flag deliberately does NOT gate this route. // Flag-gate note: this route IS now gated by the customerPortal feature
// Flipping the master toggle off in Settings → Features hides the admin // flag via the requireCustomerPortalEnabled middleware mounted in
// UI surface (sidebar entry, /admin/customers page) but does not revoke // server.js (`app.use('/api/customer/auth', requireCustomerPortalEnabled, …)`).
// access for customers who already accepted an invitation. To lock out // When the admin flips the toggle off in Settings → Features, every
// existing customers, deactivate their accounts individually // customer-side endpoint — including login — returns 410. The previous
// (customer_accounts.is_active = false) — which IS enforced below. // design left login reachable while the rest of the surface was gated;
// that was confusing and asymmetric. Single source of truth wins.
// To lock out a specific customer without disabling the feature for
// everyone, deactivate the account (customer_accounts.is_active = false).
router.post('/login', [ router.post('/login', [
body('email').isEmail().normalizeEmail().withMessage('Valid email is required'), body('email').isEmail().normalizeEmail().withMessage('Valid email is required'),
body('password').isString().notEmpty(), body('password').isString().notEmpty(),