From e88badb4f879607fc5d49eda3b7c6ddc9e89f93a Mon Sep 17 00:00:00 2001 From: gbtami Date: Thu, 9 Jan 2025 19:24:14 +0100 Subject: [PATCH] Prevent NotInAppUsers exception --- server/puzzle.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/server/puzzle.py b/server/puzzle.py index 603f5ec23..ffcb1e303 100644 --- a/server/puzzle.py +++ b/server/puzzle.py @@ -198,13 +198,14 @@ async def puzzle_vote(request): good = post_data["vote"] == "true" up_or_down = "up" if good else "down" - users = app_state.users + # Who made the request? session = await aiohttp_session.get_session(request) - try: - user = users[session.get("user_name")] - except KeyError: + session_user = session.get("user_name") + if session_user is None: return web.json_response({}) + user = await app_state.users.get(session_user) + if user.puzzles.get("puzzleId"): return web.json_response({}) else: