feat: Refactor DTOs and models to use from_attributes, update database schema references, and implement trailer types
This commit is contained in:
@@ -10,9 +10,7 @@ from typing import Optional, Dict, Any
|
||||
from sqlalchemy.orm import Session
|
||||
from .config import settings
|
||||
import logging
|
||||
from sqlalchemy.orm import Session
|
||||
from core.database import get_core_db
|
||||
from api.v1.modules.a76.user_tenant.models import UserTenant
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -76,22 +74,7 @@ async def get_current_user(
|
||||
current_user: dict = Depends(get_current_user)
|
||||
"""
|
||||
token = credentials.credentials
|
||||
user_info = verify_token(token)
|
||||
|
||||
# Obtener user_id desde el token
|
||||
user_id = user_info.get("sub")
|
||||
if not user_id:
|
||||
raise HTTPException(status_code=401, detail="User ID not found in token")
|
||||
|
||||
# Consultar la tabla user_tenant para obtener tenant_id y company_id
|
||||
user_tenant = db.query(UserTenant).filter(UserTenant.keycloak_user_id == user_id).first()
|
||||
if not user_tenant:
|
||||
raise HTTPException(status_code=403, detail="User does not have access to any tenant or company")
|
||||
|
||||
# Enriquecer user_info con tenant_id y company_id
|
||||
user_info["tenant_id"] = user_tenant.tenant_id
|
||||
user_info["company_id"] = user_tenant.company_id
|
||||
|
||||
user_info = verify_token(token)
|
||||
return user_info
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user