feat: RBAC Phase 1 — consolidate user roles into 4-value enum
Some checks failed
Some checks failed
Consolidate User.role (2-value: admin/store) + User.is_super_admin (boolean) into a single 4-value UserRole enum: super_admin, platform_admin, merchant_owner, store_member. Drop stale StoreUser.user_type column. Fix role="user" bug in merchant creation. Key changes: - Expand UserRole enum from 2 to 4 values with computed properties (is_admin, is_super_admin, is_platform_admin, is_merchant_owner, is_store_user) - Add Alembic migration (tenancy_003) for data migration + column drops - Remove is_super_admin from JWT token payload - Update all auth dependencies, services, routes, templates, JS, and tests - Update all RBAC documentation 66 files changed, 1219 unit tests passing. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
5
tests/fixtures/store_fixtures.py
vendored
5
tests/fixtures/store_fixtures.py
vendored
@@ -70,7 +70,7 @@ def test_store(db, test_merchant):
|
||||
@pytest.fixture
|
||||
def test_store_with_store_user(db, test_store_user):
|
||||
"""Create a store owned by a store user (for testing store API endpoints)."""
|
||||
from app.modules.tenancy.models import StoreUser, StoreUserType
|
||||
from app.modules.tenancy.models import StoreUser
|
||||
|
||||
unique_id = str(uuid.uuid4())[:8].upper()
|
||||
|
||||
@@ -98,11 +98,10 @@ def test_store_with_store_user(db, test_store_user):
|
||||
db.commit()
|
||||
db.refresh(store)
|
||||
|
||||
# Create StoreUser association
|
||||
# Create StoreUser association (ownership determined via Merchant.owner_user_id)
|
||||
store_user = StoreUser(
|
||||
store_id=store.id,
|
||||
user_id=test_store_user.id,
|
||||
user_type=StoreUserType.OWNER.value,
|
||||
is_active=True,
|
||||
)
|
||||
db.add(store_user)
|
||||
|
||||
Reference in New Issue
Block a user