Fix user delete flow 8
This commit is contained in:
@@ -206,7 +206,7 @@ class AuthMiddleware(BaseHTTPMiddleware):
|
||||
service_name = payload["service"]
|
||||
base_context["service"] = service_name
|
||||
base_context["type"] = "service"
|
||||
base_context["role"] = "service"
|
||||
base_context["role"] = "admin"
|
||||
base_context["user_id"] = f"{service_name}-service"
|
||||
base_context["email"] = f"{service_name}-service@internal"
|
||||
logger.debug(f"Service authentication: {payload['service']}")
|
||||
|
||||
@@ -292,11 +292,24 @@ async def delete_tenant_complete(
|
||||
@router.get("/tenants/user/{user_id}")
|
||||
async def get_user_tenants(
|
||||
user_id: str,
|
||||
current_user = Depends(require_admin_role_dep),
|
||||
current_user = Depends(get_current_user_dep),
|
||||
db: AsyncSession = Depends(get_db)
|
||||
):
|
||||
|
||||
"""Get all tenant memberships for a user (admin only)"""
|
||||
|
||||
# Check if this is a service call or admin user
|
||||
user_type = current_user.get('type', '')
|
||||
user_role = current_user.get('role', '').lower()
|
||||
|
||||
logger.info("The user_type and user_role", user_type=user_type, user_role=user_role)
|
||||
|
||||
if user_type != 'service' and user_role != 'admin':
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_403_FORBIDDEN,
|
||||
detail="Admin role or service authentication required"
|
||||
)
|
||||
|
||||
try:
|
||||
user_uuid = uuid.UUID(user_id)
|
||||
except ValueError:
|
||||
|
||||
Reference in New Issue
Block a user