Files
Webklar-Kundenbereich/server/services/shop/schalter.js
T
ClaudeandClaude Opus 5.5 e9ab15bdb5 Webshop A1/A2: Konfiguration, Schalter, Katalog shopSetup, Schema und Setup-Skript
config.shop (SHOP_ENABLED, SHOP_PILOT_EMAILS, SHOP_UPLOAD_DIR, STRIPE_CONNECT_WEBHOOK_SECRET), config.shopSetup (299 € einmalig),
Collection-IDs shopConfig/shopProducts/shopOrders/shopWiderrufe, services/shop/schalter.js, Katalogschluessel shopSetup in
stripeBilling und stripe-products.mjs, services/shop/schema.js, scripts/shop-setup.mjs (--check), schemaKeys fuer die Test-Mocks.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-05 08:30:21 +00:00

27 lines
955 B
JavaScript

import { config } from '../../config.js'
/**
* Webshop-Schalter (Funktionsschluessel 'shop'): SHOP_ENABLED = off (Vorgabe) | pilot | on.
* Liest config.shop bei jedem Aufruf. Bei off laufen keine Shop-Jobs und keine Shop-Abfragen.
*/
/** 'off' | 'pilot' | 'on'; alles andere (leer, unbekannt) gilt als off. */
export function shopModus() {
const mode = config.shop.mode
return mode === 'pilot' || mode === 'on' ? mode : 'off'
}
/**
* Darf dieser Kunde den Webshop nutzen? pilot = nur Adressen aus SHOP_PILOT_EMAILS ('*' = alle; eine leere
* Liste laesst niemanden durch); on = alle Kunden; off = niemand.
*/
export function shopFuerKunde(email) {
const modus = shopModus()
if (modus === 'off') return false
if (modus === 'on') return true
const erlaubt = config.shop.pilotEmails
if (erlaubt.includes('*')) return true
const adresse = String(email || '').trim().toLowerCase()
return adresse !== '' && erlaubt.includes(adresse)
}