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)