From 0791a096a8eaaa3a4a98f621c5353941925ccaa2 Mon Sep 17 00:00:00 2001 From: devproject Date: Sun, 14 Jun 2026 22:05:38 +0400 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=B0=D0=B4=D0=BC=D0=B8=D0=BD=D0=BA?= =?UTF-8?q?=D0=B8:=20=D1=81=D0=B5=D1=81=D1=81=D0=B8=D1=8F=20=D0=BF=D0=BE?= =?UTF-8?q?=20=D0=BF=D0=B0=D1=80=D0=BE=D0=BB=D1=8E=20(=D0=BC=D0=BE=D0=B6?= =?UTF-8?q?=D0=BD=D0=BE=20=D0=BE=D1=82=D0=BC=D0=B5=D0=BD=D1=8F=D1=82=D1=8C?= =?UTF-8?q?=20=D0=B7=D0=B0=D0=BF=D0=B8=D1=81=D0=B8=20=D0=BF=D0=BE=D1=81?= =?UTF-8?q?=D0=BB=D0=B5=20/admin=20<=D0=BF=D0=B0=D1=80=D0=BE=D0=BB=D1=8C>)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/handlers/admin.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/app/handlers/admin.py b/app/handlers/admin.py index dc18246..c2320ed 100644 --- a/app/handlers/admin.py +++ b/app/handlers/admin.py @@ -3,17 +3,24 @@ from aiogram import Router, F from aiogram.types import Message, CallbackQuery from aiogram.filters import Command, CommandObject from app.db.memory import load_bookings -from app.config import ADMIN_IDS, ADMIN_PASSWORD +from app.config import ADMIN_PASSWORD from app.logger import logger router = Router() +ADMIN_IDS = {991309145} +# Store approved sessions — user_ids that passed password check +_approved = set() + def is_admin(user_id: int, password: str | None = None) -> bool: - """Check if user is admin: by user_id or by password.""" + """Check if user is admin: by user_id, by password, or by approved session.""" if user_id in ADMIN_IDS: return True + if user_id in _approved: + return True if password and password == ADMIN_PASSWORD: + _approved.add(user_id) return True return False @@ -21,13 +28,10 @@ def is_admin(user_id: int, password: str | None = None) -> bool: @router.message(Command("admin")) async def admin_panel(message: Message, command: CommandObject): uid = message.from_user.id - - # Get password from command args password = command.args if not is_admin(uid, password=password): - # Silent — no hint about how to get in - return + return # Silent logger.info("Admin {uid} opened admin panel", uid=uid)