Update environment variables in docker-compose and refactor RLS context handling in database and middleware. Added error handling for Hub license verification.
This commit is contained in:
@@ -9,7 +9,12 @@ from sqlalchemy.orm import Session
|
||||
|
||||
from api.v1.modules.a76.general_catalogs.company.models import Company
|
||||
from api.v1.modules.a76.invoices.models import InvoiceHeader
|
||||
from core.database import rls_company_var, rls_tenant_var
|
||||
from core.database import (
|
||||
RLS_COMPANY_KEY,
|
||||
RLS_TENANT_KEY,
|
||||
rls_company_var,
|
||||
rls_tenant_var,
|
||||
)
|
||||
|
||||
from .services.service import AuditService
|
||||
from .utils.serialization import serialize_for_json
|
||||
@@ -56,13 +61,17 @@ def _resolve_audit_company_tenant(session: Session, target) -> tuple:
|
||||
if company_id is not None:
|
||||
resolution_source = "company_self_id"
|
||||
if company_id is None:
|
||||
company_id = rls_company_var.get()
|
||||
company_id = session.info.get(RLS_COMPANY_KEY)
|
||||
if company_id is None:
|
||||
company_id = rls_company_var.get()
|
||||
if company_id is not None:
|
||||
resolution_source = "rls_context"
|
||||
|
||||
tenant_id = getattr(target, "tenant_id", None)
|
||||
if tenant_id is None:
|
||||
tenant_id = rls_tenant_var.get()
|
||||
tenant_id = session.info.get(RLS_TENANT_KEY)
|
||||
if tenant_id is None:
|
||||
tenant_id = rls_tenant_var.get()
|
||||
if tenant_id is not None and resolution_source == "target":
|
||||
resolution_source = "rls_context"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user