fix(tenancy): use is_production() for invitation URL instead of debug flag
All checks were successful
CI / ruff (push) Successful in 15s
CI / pytest (push) Successful in 2h52m50s
CI / validate (push) Successful in 28s
CI / dependency-scanning (push) Successful in 34s
CI / docs (push) Successful in 51s
CI / deploy (push) Successful in 1m19s

Using debug flag for environment detection is unreliable — if left
True in prod, links would point to localhost. Now uses the proper
is_production() from environment module.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-29 17:49:31 +02:00
parent bc5e227d81
commit 2a15c14ee8
4 changed files with 26 additions and 20 deletions

View File

@@ -981,18 +981,17 @@ class StoreTeamService:
):
"""Send team invitation email."""
from app.core.config import settings as app_settings
from app.core.environment import is_production
from app.modules.messaging.services.email_service import EmailService
# Build acceptance URL using store's subdomain or main domain
store_subdomain = store.subdomain
# Build acceptance URL
# Prod: https://{subdomain}.{main_domain}/invitation/accept?token=...
# Dev: http://localhost:8000/store/{store_code}/invitation/accept?token=...
main_domain = app_settings.main_domain.rstrip("/")
if app_settings.debug or "localhost" in main_domain:
# Dev: use localhost with store path
base_url = f"http://localhost:8000/store/{store.store_code}"
if is_production():
base_url = f"https://{store.subdomain}.{main_domain}"
else:
# Prod: use store subdomain
base_url = f"https://{store_subdomain}.{main_domain}"
base_url = f"http://localhost:8000/store/{store.store_code}"
acceptance_link = f"{base_url}/invitation/accept?token={token}"