limpieza de scipts
This commit is contained in:
@@ -1,67 +0,0 @@
|
||||
import re
|
||||
|
||||
with open("/app/app/api/v1/endpoints/auth.py", "r") as f:
|
||||
content = f.read()
|
||||
|
||||
old = ''' # 1. Validar tenant
|
||||
tenant_result = await db.execute(
|
||||
select(Tenant).where(Tenant.slug == login_data.tenant_slug)
|
||||
)
|
||||
tenant = tenant_result.scalar_one_or_none()
|
||||
if tenant is None:
|
||||
logger.warning(
|
||||
"Login failed - tenant not found",
|
||||
email=login_data.email,
|
||||
tenant_slug=login_data.tenant_slug,
|
||||
)
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_404_NOT_FOUND,
|
||||
detail="Tenant not found",
|
||||
)'''
|
||||
|
||||
new = ''' # 1. Validar tenant - por slug si viene, sino detectar por email
|
||||
if login_data.tenant_slug:
|
||||
tenant_result = await db.execute(
|
||||
select(Tenant).where(Tenant.slug == login_data.tenant_slug)
|
||||
)
|
||||
tenant = tenant_result.scalar_one_or_none()
|
||||
if tenant is None:
|
||||
raise HTTPException(
|
||||
status_code=status.HTTP_404_NOT_FOUND,
|
||||
detail="Tenant not found",
|
||||
)
|
||||
else:
|
||||
tenant = None'''
|
||||
|
||||
if old in content:
|
||||
content = content.replace(old, new)
|
||||
print("OK: bloque tenant reemplazado")
|
||||
else:
|
||||
print("ERROR: bloque no encontrado")
|
||||
|
||||
# Tambien actualizar la query de usuario para usar tenant o no
|
||||
old2 = ''' # 2. Buscar usuario en base de datos (aislado por tenant)
|
||||
query = select(User).where(
|
||||
User.email == login_data.email,
|
||||
User.tenant_id == tenant.id,
|
||||
)'''
|
||||
|
||||
new2 = ''' # 2. Buscar usuario - filtrar por tenant si se detecto, sino buscar por email
|
||||
if tenant:
|
||||
query = select(User).where(
|
||||
User.email == login_data.email,
|
||||
User.tenant_id == tenant.id,
|
||||
)
|
||||
else:
|
||||
query = select(User).where(User.email == login_data.email)'''
|
||||
|
||||
if old2 in content:
|
||||
content = content.replace(old2, new2)
|
||||
print("OK: bloque query reemplazado")
|
||||
else:
|
||||
print("ERROR: bloque query no encontrado")
|
||||
|
||||
with open("/app/app/api/v1/endpoints/auth.py", "w") as f:
|
||||
f.write(content)
|
||||
|
||||
print("Listo")
|
||||
@@ -1,23 +0,0 @@
|
||||
with open("/app/app/api/v1/endpoints/auth.py", "r") as f:
|
||||
content = f.read()
|
||||
|
||||
old = ''' # Rate limiting (best-effort): by (tenant,email) to slow brute force.
|
||||
ident_key = None
|
||||
if settings.RATE_LIMIT_ENABLED and not settings.TESTING:
|
||||
email_norm = login_data.email.strip().lower()
|
||||
ident_key = cache_key("rl", "login", "id", str(tenant.id), email_norm)'''
|
||||
|
||||
new = ''' # Rate limiting (best-effort): by (tenant,email) to slow brute force.
|
||||
ident_key = None
|
||||
if settings.RATE_LIMIT_ENABLED and not settings.TESTING and tenant:
|
||||
email_norm = login_data.email.strip().lower()
|
||||
ident_key = cache_key("rl", "login", "id", str(tenant.id), email_norm)'''
|
||||
|
||||
if old in content:
|
||||
content = content.replace(old, new)
|
||||
print("OK: rate limiting fix aplicado")
|
||||
else:
|
||||
print("ERROR: bloque no encontrado")
|
||||
|
||||
with open("/app/app/api/v1/endpoints/auth.py", "w") as f:
|
||||
f.write(content)
|
||||
Reference in New Issue
Block a user