Merge branch 'development' into feature/Invoice-movements
This commit is contained in:
@@ -13,7 +13,9 @@ celery_app = Celery(
|
||||
"api.v1.modules.a76.reports.importacion.consolidados.task",
|
||||
"api.v1.modules.a76.reports.importacion.packing_list.task",
|
||||
"api.v1.modules.a76.reports.exportacion.aviso_consolidado.task",
|
||||
"api.v1.modules.a76.reports.movements.invoices.tasks"
|
||||
"api.v1.modules.a76.reports.movements.invoices.tasks",
|
||||
"api.v1.modules.a76.reports.exportacion.descargo.task",
|
||||
"api.v1.modules.a76.imports.tasks"
|
||||
] # Ruta al módulo donde están las tareas
|
||||
)
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
Configuración centralizada de la aplicación usando Pydantic Settings
|
||||
"""
|
||||
|
||||
import os
|
||||
from typing import List
|
||||
|
||||
from pydantic_settings import BaseSettings, SettingsConfigDict
|
||||
@@ -12,7 +13,9 @@ class Settings(BaseSettings):
|
||||
|
||||
# Application
|
||||
APP_NAME: str = "Anexo76"
|
||||
APP_VERSION: str = "1.0.0"
|
||||
# La versión se obtiene de la variable de entorno APP_VERSION que se pasa desde Docker
|
||||
# Si no existe, usa un valor por defecto de desarrollo
|
||||
APP_VERSION: str = os.getenv("APP_VERSION", "dev-local")
|
||||
DEBUG: bool = True
|
||||
ENVIRONMENT: str = "development"
|
||||
|
||||
|
||||
10
backend/core/context.py
Normal file
10
backend/core/context.py
Normal file
@@ -0,0 +1,10 @@
|
||||
from contextvars import ContextVar
|
||||
from typing import Optional, Dict, Any
|
||||
|
||||
_user_context: ContextVar[Optional[Dict[str, Any]]] = ContextVar("user_context", default=None)
|
||||
|
||||
def get_user_context() -> Optional[Dict[str, Any]]:
|
||||
return _user_context.get()
|
||||
|
||||
def set_user_context(user: Dict[str, Any]) -> None:
|
||||
_user_context.set(user)
|
||||
@@ -171,8 +171,9 @@ def validate_company_access(
|
||||
)
|
||||
|
||||
return company is not None
|
||||
finally:
|
||||
db.close()
|
||||
except Exception as e:
|
||||
logger.error(f"Error validating company access: {str(e)}")
|
||||
return False
|
||||
|
||||
|
||||
def validate_access_to_resource(
|
||||
@@ -200,7 +201,12 @@ def validate_access_to_resource(
|
||||
HTTPException: Si no hay tenant_id, no tiene acceso o no tiene los permisos requeridos
|
||||
"""
|
||||
|
||||
tenant_id = current_user.get("tenant_id")
|
||||
tenant_id = get_tenant_from_token(current_user)
|
||||
if not tenant_id:
|
||||
# Fallback para desarrollo o tokens mal formados que sí tienen el atributo pero en otro lado
|
||||
# Esto evita el 400 si get_tenant_from_token falla pero el usuario es válido
|
||||
tenant_id = current_user.get("tenant_id")
|
||||
|
||||
if not tenant_id:
|
||||
raise HTTPException(status_code=400, detail="Tenant ID not found in token")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user