diff --git a/dashboard/backend/routers/auth.py b/dashboard/backend/routers/auth.py index c467a5f..478362d 100644 --- a/dashboard/backend/routers/auth.py +++ b/dashboard/backend/routers/auth.py @@ -1,6 +1,5 @@ from datetime import timedelta import asyncio -import os import httpx from fastapi import APIRouter, Depends, HTTPException, status, Request from pydantic import BaseModel @@ -36,11 +35,11 @@ async def send_failed_login_alert(ip_address: str, username: str, reason: str): return msg = f"🚨 *Dashboard Security Alert* 🚨\nFailed login attempt detected.\n\nšŸ‘¤ User: `{username}`\n🌐 IP: `{ip_address}`\nāŒ Reason: {reason}" try: + client_options = {} if config.TELEGRAM_PROXY: - os.environ["HTTP_PROXY"] = config.TELEGRAM_PROXY - os.environ["HTTPS_PROXY"] = config.TELEGRAM_PROXY + client_options["proxy"] = config.TELEGRAM_PROXY - async with httpx.AsyncClient() as client: + async with httpx.AsyncClient(**client_options) as client: res = await client.post( f"https://api.telegram.org/bot{config.TELEGRAM_BOT_TOKEN}/sendMessage", data={"chat_id": config.TELEGRAM_CHAT_ID, "text": msg, "parse_mode": "Markdown"},