diff --git a/backend/api/v1/modules/core/invites/routes.py b/backend/api/v1/modules/core/invites/routes.py index 15912707..9a9225fd 100644 --- a/backend/api/v1/modules/core/invites/routes.py +++ b/backend/api/v1/modules/core/invites/routes.py @@ -4,7 +4,6 @@ import logging from core.database import get_core_db from core.security import get_current_user, validate_access_to_resource -from core.config import settings from fastapi import APIRouter, Depends, Query, Request from sqlalchemy.orm import Session @@ -37,12 +36,10 @@ async def create_invite( tenant_slug: str = current_user.get("tenant_slug") or "" created_by: str = current_user.get("sub") or "" - base_url = settings.APP_PUBLIC_URL.rstrip("/") service = InviteService(db) return await service.create_invite( data=data, created_by=created_by, tenant_slug=tenant_slug, - base_url=base_url, ) diff --git a/backend/api/v1/modules/core/invites/service.py b/backend/api/v1/modules/core/invites/service.py index 4170a31a..447ad72d 100644 --- a/backend/api/v1/modules/core/invites/service.py +++ b/backend/api/v1/modules/core/invites/service.py @@ -45,7 +45,6 @@ class InviteService: data: CreateInviteDTO, created_by: str, tenant_slug: str, - base_url: str, ) -> InviteResponseDTO: import httpx from api.v1.modules.core.tenants.models import Tenant @@ -99,10 +98,11 @@ class InviteService: except Exception as exc: logger.warning("Hub invite creation failed (non-blocking): %s", exc) - # Fallback: URL local si el Hub falló + # Fallback: URL del workspace (Hub) si la creación de invitación en Hub falló if not invite_url: + hub_base = settings.HUB_URL.rstrip("/") invite_url = ( - f"{base_url}/register" + f"{hub_base}/register" f"?invite_token={token_plain}" f"&tenant={tenant_slug}" f"&email={data.email}" diff --git a/backend/core/middleware.py b/backend/core/middleware.py index 1bb5836d..8c827fc2 100644 --- a/backend/core/middleware.py +++ b/backend/core/middleware.py @@ -34,7 +34,7 @@ def _is_token_issue_message(*values: str | None) -> bool: has_invalid_marker = any(marker in text for marker in invalid_markers) has_expired_marker = any(marker in text for marker in expired_markers) - return has_expired_marker or (has_token_context and has_invalid_marker) + return (has_expired_marker and has_token_context) or (has_token_context and has_invalid_marker) def _extract_company_id(request: Request) -> Optional[int]: