feat: remove migration for hub_invite_token from invite_tokens table
This commit is contained in:
@@ -688,7 +688,7 @@ def validate_access_to_resource(
|
||||
current_user: Dict[str, Any],
|
||||
required_permissions: Optional[list[str]] = None,
|
||||
require_all: bool = True,
|
||||
) -> int:
|
||||
) -> Optional[int]:
|
||||
"""
|
||||
Valida que el usuario tenga acceso a un recurso específico basado en company_id
|
||||
y regresa el tenant_id. Opcionalmente verifica permisos.
|
||||
@@ -786,4 +786,13 @@ def validate_access_to_resource(
|
||||
if not has_access:
|
||||
raise HTTPException(status_code=403, detail="Permission denied")
|
||||
|
||||
return tenant_id or 1
|
||||
# Nunca sustituir tenant_id=None/0 silenciosamente — un valor inválido aquí
|
||||
# significaría acceso al tenant equivocado. Si llegamos aquí sin tenant_id
|
||||
# válido para un usuario no-admin, es un estado inconsistente que debe fallar.
|
||||
if not isinstance(tenant_id, int) or tenant_id <= 0:
|
||||
if not is_keycloak_admin:
|
||||
raise HTTPException(
|
||||
status_code=400,
|
||||
detail="No se pudo determinar el tenant_id para la empresa especificada",
|
||||
)
|
||||
return tenant_id # puede ser None solo para hub_admin sin required_permissions (acceso global)
|
||||
|
||||
Reference in New Issue
Block a user