fix: store login crash and dashboard misrouted as storefront
Some checks failed
Some checks failed
- Seed default RBAC roles per store and assign role_id to StoreUser records (was never implemented after RBAC Phase 1 cleanup) - Handle nullable role in auth_service find_user_store and get_user_store_role to prevent NoneType crash on login - Use platform_clean_path instead of clean_path in FrontendTypeMiddleware so /store/X/dashboard is detected as STORE, not STOREFRONT Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -43,8 +43,11 @@ class FrontendTypeMiddleware(BaseHTTPMiddleware):
|
||||
async def dispatch(self, request: Request, call_next):
|
||||
"""Detect frontend type and inject into request state."""
|
||||
host = request.headers.get("host", "")
|
||||
# Use clean_path if available (from store_context_middleware), else original path
|
||||
path = getattr(request.state, "clean_path", None) or request.url.path
|
||||
# Use platform_clean_path (platform prefix stripped, store prefix retained)
|
||||
# so FrontendDetector can distinguish /store/ from /storefront/.
|
||||
# Do NOT use clean_path here — it has the store prefix stripped too,
|
||||
# which makes /store/X/dashboard indistinguishable from /storefront/X/products.
|
||||
path = getattr(request.state, "platform_clean_path", None) or request.url.path
|
||||
|
||||
# Check if store context exists (set by StoreContextMiddleware)
|
||||
has_store_context = (
|
||||
|
||||
Reference in New Issue
Block a user