refactor(demo): Standardize demo account type names across codebase
Standardize demo account type naming from inconsistent variants to clean names: - individual_bakery, professional_bakery → professional - central_baker, enterprise_chain → enterprise This eliminates naming confusion that was causing bugs in the demo session initialization, particularly for enterprise demo tenants where different parts of the system used different names for the same concept. Changes: - Updated source of truth in demo_session config - Updated all backend services (middleware, cloning, orchestration) - Updated frontend types, pages, and stores - Updated demo session models and schemas - Removed all backward compatibility code as requested Related to: Enterprise demo session access fix 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -8,15 +8,29 @@ from fastapi.responses import JSONResponse
|
||||
from starlette.middleware.base import BaseHTTPMiddleware
|
||||
from starlette.responses import Response
|
||||
from typing import Optional
|
||||
import uuid
|
||||
import httpx
|
||||
import structlog
|
||||
|
||||
logger = structlog.get_logger()
|
||||
|
||||
# Fixed Demo Tenant IDs (these are the template tenants that will be cloned)
|
||||
# Professional demo (merged from San Pablo + La Espiga)
|
||||
DEMO_TENANT_PROFESSIONAL = uuid.UUID("a1b2c3d4-e5f6-47a8-b9c0-d1e2f3a4b5c6")
|
||||
|
||||
# Enterprise chain demo (parent + 3 children)
|
||||
DEMO_TENANT_ENTERPRISE_CHAIN = uuid.UUID("c3d4e5f6-a7b8-49c0-d1e2-f3a4b5c6d7e8")
|
||||
DEMO_TENANT_CHILD_1 = uuid.UUID("d4e5f6a7-b8c9-40d1-e2f3-a4b5c6d7e8f9")
|
||||
DEMO_TENANT_CHILD_2 = uuid.UUID("e5f6a7b8-c9d0-41e2-f3a4-b5c6d7e8f9a0")
|
||||
DEMO_TENANT_CHILD_3 = uuid.UUID("f6a7b8c9-d0e1-42f3-a4b5-c6d7e8f9a0b1")
|
||||
|
||||
# Demo tenant IDs (base templates)
|
||||
DEMO_TENANT_IDS = {
|
||||
"a1b2c3d4-e5f6-g7h8-i9j0-k1l2m3n4o5p6", # Panadería San Pablo
|
||||
"b2c3d4e5-f6g7-h8i9-j0k1-l2m3n4o5p6q7", # Panadería La Espiga
|
||||
str(DEMO_TENANT_PROFESSIONAL), # Professional demo tenant
|
||||
str(DEMO_TENANT_ENTERPRISE_CHAIN), # Enterprise chain parent
|
||||
str(DEMO_TENANT_CHILD_1), # Enterprise chain child 1
|
||||
str(DEMO_TENANT_CHILD_2), # Enterprise chain child 2
|
||||
str(DEMO_TENANT_CHILD_3), # Enterprise chain child 3
|
||||
}
|
||||
|
||||
# Allowed operations for demo accounts (limited write)
|
||||
@@ -117,12 +131,12 @@ class DemoMiddleware(BaseHTTPMiddleware):
|
||||
# Inject demo user context for auth middleware
|
||||
# Map demo account type to the actual demo user IDs from seed_demo_users.py
|
||||
DEMO_USER_IDS = {
|
||||
"individual_bakery": "c1a2b3c4-d5e6-47a8-b9c0-d1e2f3a4b5c6", # María García López
|
||||
"central_baker": "d2e3f4a5-b6c7-48d9-e0f1-a2b3c4d5e6f7" # Carlos Martínez Ruiz
|
||||
"professional": "c1a2b3c4-d5e6-47a8-b9c0-d1e2f3a4b5c6", # María García López
|
||||
"enterprise": "d2e3f4a5-b6c7-48d9-e0f1-a2b3c4d5e6f7" # Carlos Martínez Ruiz
|
||||
}
|
||||
demo_user_id = DEMO_USER_IDS.get(
|
||||
session_info.get("demo_account_type", "individual_bakery"),
|
||||
DEMO_USER_IDS["individual_bakery"]
|
||||
session_info.get("demo_account_type", "professional"),
|
||||
DEMO_USER_IDS["professional"]
|
||||
)
|
||||
|
||||
# This allows the request to pass through AuthMiddleware
|
||||
|
||||
Reference in New Issue
Block a user