diff options
Diffstat (limited to 'api/game/accept.py')
-rw-r--r-- | api/game/accept.py | 18 |
1 files changed, 3 insertions, 15 deletions
diff --git a/api/game/accept.py b/api/game/accept.py index 66f20b6..36bc018 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 auth.login_token import token_login +from hierarchy import auth_required from game.info import valid_game_id from socket_io import io from game.new import start_game @@ -13,20 +13,8 @@ from game.new import start_game join_game = Blueprint('game_accept', __name__) @join_game.route('/accept', methods = ['POST']) -def index(): - data = request.get_json() - - token = request.cookies.get("token") or "" - game_id = data.get("id") or "" - - if not valid_game_id(game_id): return "", 403 - - if not token: - print("a temporary user should be set up here") - - user_id = token_login(token) - if not user_id: return "", 403 - +@auth_required("user") +def index(user_id): if cursor.execute("select status from games where game_id = ?", [game_id]).fetchone()[0] != "wait_for_opponent": return "", 403 |