The require_module_access dependency was using path-based detection to determine admin vs vendor authentication, which failed for API routes (/api/v1/admin/*) because it only checked for /admin/*. Changes: - Make frontend_type parameter mandatory (was optional with fallback) - Remove path-based detection logic from require_module_access - Update all 33 module route files to pass explicit FrontendType: - 15 admin routes use FrontendType.ADMIN - 18 vendor routes use FrontendType.VENDOR This ensures authentication method is explicitly declared at route definition time, making it independent of URL structure and future-proof for API version changes. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
31 lines
1.2 KiB
Python
31 lines
1.2 KiB
Python
# app/modules/messaging/routes/api/vendor.py
|
|
"""
|
|
Messaging module vendor API routes.
|
|
|
|
Aggregates all vendor messaging routes:
|
|
- /messages/* - Conversation and message management
|
|
- /notifications/* - Vendor notifications
|
|
- /email-settings/* - SMTP and provider configuration
|
|
- /email-templates/* - Email template customization
|
|
"""
|
|
|
|
from fastapi import APIRouter, Depends
|
|
|
|
from app.api.deps import require_module_access
|
|
from app.modules.enums import FrontendType
|
|
|
|
from .vendor_messages import vendor_messages_router
|
|
from .vendor_notifications import vendor_notifications_router
|
|
from .vendor_email_settings import vendor_email_settings_router
|
|
from .vendor_email_templates import vendor_email_templates_router
|
|
|
|
vendor_router = APIRouter(
|
|
dependencies=[Depends(require_module_access("messaging", FrontendType.VENDOR))],
|
|
)
|
|
|
|
# Aggregate all messaging vendor routes
|
|
vendor_router.include_router(vendor_messages_router, tags=["vendor-messages"])
|
|
vendor_router.include_router(vendor_notifications_router, tags=["vendor-notifications"])
|
|
vendor_router.include_router(vendor_email_settings_router, tags=["vendor-email-settings"])
|
|
vendor_router.include_router(vendor_email_templates_router, tags=["vendor-email-templates"])
|