Fix user delete flow 9

This commit is contained in:
Urtzi Alfaro
2025-08-02 23:29:18 +02:00
parent 826df76029
commit abe74f32f8
6 changed files with 49 additions and 3 deletions

View File

@@ -301,10 +301,15 @@ async def get_user_tenants(
# Check if this is a service call or admin user
user_type = current_user.get('type', '')
user_role = current_user.get('role', '').lower()
service_name = current_user.get('service', '')
logger.info("The user_type and user_role", user_type=user_type, user_role=user_role)
if user_type != 'service' and user_role != 'admin':
# ✅ IMPROVED: Accept service tokens OR admin users
is_service_token = (user_type == 'service' or service_name in ['auth', 'admin'])
is_admin_user = (user_role == 'admin')
if not (is_service_token or is_admin_user):
raise HTTPException(
status_code=status.HTTP_403_FORBIDDEN,
detail="Admin role or service authentication required"