diff options
author | lonkaars <l.leblansch@gmail.com> | 2021-04-16 16:56:23 +0200 |
---|---|---|
committer | lonkaars <l.leblansch@gmail.com> | 2021-04-16 16:56:23 +0200 |
commit | aa2c999702dadba2afbcf2be9f597f890aafcc87 (patch) | |
tree | 72828d9d478b2f839f78e65d143bf4363f4ed8af /api/game | |
parent | b9e1d1537bb9b8b178d9d6cb7aca06d8cfc068a4 (diff) |
fix api/game/accept
Diffstat (limited to 'api/game')
-rw-r--r-- | api/game/accept.py | 7 | ||||
-rw-r--r-- | api/game/socket.py | 4 |
2 files changed, 6 insertions, 5 deletions
diff --git a/api/game/accept.py b/api/game/accept.py index 1f73fd1..3510ffd 100644 --- a/api/game/accept.py +++ b/api/game/accept.py @@ -5,7 +5,7 @@ import time import json import random from game.socket import game, games -from hierarchy import auth_required +from hierarchy import game_id_with_viewer from socket_io import io from game.new import start_game @@ -14,8 +14,9 @@ join_game = Blueprint('game_accept', __name__) # join a game by game_id (public or private) @join_game.route('/accept', methods=['POST']) -@auth_required("user") #FIXME: this doesn't work haha i don't know when i wrote this -def index(game_id): +@game_id_with_viewer +def index(game_id, user_id): + if not user_id: return "", 400 if cursor.execute("select status from games where game_id = ?", [game_id]).fetchone()[0] != "wait_for_opponent": return "", 403 diff --git a/api/game/socket.py b/api/game/socket.py index 69dc07e..ca28346 100644 --- a/api/game/socket.py +++ b/api/game/socket.py @@ -22,12 +22,12 @@ def participants_only(func): game_id = data["game_id"] if not game_id or \ - not game_id in games: + not game_id in games: return game = games[game_id] if game.player_1_id != user_id and \ - game.player_2_id != user_id: + game.player_2_id != user_id: return return func(data, user_id, game) |