Skip to content

Commit

Permalink
Prevent NotInAppUsers exception
Browse files Browse the repository at this point in the history
  • Loading branch information
gbtami committed Jan 9, 2025
1 parent e88badb commit 43c8f92
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions server/puzzle.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from const import VARIANTS
from fairy import FairyBoard
from glicko2.glicko2 import MU, gl2, Rating, rating
from users import NotInAppUsers
from pychess_global_app_state_utils import get_app_state

# variants having 0 puzzle so far
Expand Down Expand Up @@ -154,13 +153,14 @@ async def puzzle_complete(request):

await puzzle.set_played()

users = app_state.users
# Who made the request?
session = await aiohttp_session.get_session(request)
try:
user = users[session.get("user_name")]
except NotInAppUsers:
session_user = session.get("user_name")
if session_user is None:
return web.json_response({})

user = await app_state.users.get(session_user)

if puzzleId in user.puzzles:
return web.json_response({})
else:
Expand Down

0 comments on commit 43c8f92

Please sign in to comment.