add first users to join game to game record
This commit is contained in:
parent
8b6fe54866
commit
e14eca3552
2 changed files with 8 additions and 1 deletions
|
@ -19,7 +19,12 @@ def get_room(game_id):
|
|||
# TODO create decorator that returns user from header
|
||||
auth_header = request.headers.get('Authorization')
|
||||
user = jwt.decode(auth_header.split(" ")[1], os.environ.get('SECRET_KEY'))['user']
|
||||
print(user)
|
||||
user = json.loads(user)
|
||||
if not game.player_black and game.player_white != user['id']:
|
||||
game.player_black = user['id']
|
||||
db.session.add(game)
|
||||
db.session.commit()
|
||||
print(game_schema.dumps(game))
|
||||
join_game_notice(game_id, user)
|
||||
return jsonify(response)
|
||||
|
||||
|
|
|
@ -80,6 +80,8 @@ class GameSchema(ma.ModelSchema):
|
|||
board_size = fields.Int()
|
||||
player = fields.Nested(user_schema)
|
||||
game_room = fields.Int()
|
||||
player_black = fields.Int()
|
||||
player_white = fields.Int()
|
||||
|
||||
game_schema = GameSchema()
|
||||
games_schema = GameSchema(many=True)
|
Loading…
Reference in a new issue