소스 검색

Enforce GET params serverside

Pjotir 10 달 전
부모
커밋
a734a2c5ca
1개의 변경된 파일7개의 추가작업 그리고 3개의 파일을 삭제
  1. 7 3
      flaskapp.py

+ 7 - 3
flaskapp.py

@@ -30,9 +30,13 @@ def new_game():
     try:
         app.logger.info("Creating game...")
         name = request.args["playerName"]
-        hand_size = request.args["handSize"]
-        match_count = request.args["matchCount"]
-        turn_count = request.args["turnCount"]
+        hand_size = int(request.args["handSize"])
+        match_count = int(request.args["matchCount"])
+        turn_count = int(request.args["turnCount"])
+
+        if not name or not hand_size or not match_count or not turn_count:
+            raise KeyError
+
     except (KeyError, TypeError) as e:
         app.logger.error(e)
         app.logger.error("Failed, bad args")