fix: store login crash and dashboard misrouted as storefront
Some checks failed
CI / ruff (push) Successful in 10s
CI / pytest (push) Failing after 44m20s
CI / validate (push) Successful in 22s
CI / dependency-scanning (push) Successful in 27s
CI / docs (push) Has been skipped
CI / deploy (push) Has been skipped

- 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:
2026-02-24 01:19:22 +01:00
parent 05d31a7fc5
commit cd935988c4
3 changed files with 61 additions and 7 deletions

View File

@@ -131,7 +131,8 @@ class AuthService:
)
if store_user:
return True, store_user.role.name
role_name = store_user.role.name if store_user.role else "staff"
return True, role_name
return False, None
@@ -213,7 +214,8 @@ class AuthService:
(vm for vm in user.store_memberships if vm.is_active), None
)
if active_membership:
return active_membership.store, active_membership.role.name
role_name = active_membership.role.name if active_membership.role else "staff"
return active_membership.store, role_name
return None, None