Fix bug password and tournament

This commit is contained in:
Kum1ta
2024-11-22 23:22:14 +01:00
parent 943afda2f7
commit 395bbd8a5f
5 changed files with 36 additions and 33 deletions

View File

@ -59,12 +59,12 @@ services:
- postgres:/var/lib/postgresql/13/main - postgres:/var/lib/postgresql/13/main
restart: always restart: always
# adminer: # adminer:
# container_name: adminer # container_name: adminer
# image: adminer:latest # image: adminer:latest
# restart: always # restart: always
# networks: # networks:
# - transcendence # - transcendence
volumes: volumes:
postgres: postgres:

View File

@ -6,7 +6,7 @@
# By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ # # By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ # # +#+#+#+#+#+ +#+ #
# Created: 2024/09/25 23:28:49 by edbernar #+# #+# # # Created: 2024/09/25 23:28:49 by edbernar #+# #+# #
# Updated: 2024/09/27 16:00:05 by tomoron ### ########.fr # # Updated: 2024/11/22 23:00:54 by edbernar ### ########.fr #
# # # #
# **************************************************************************** # # **************************************************************************** #
@ -17,7 +17,7 @@ import hashlib
import json import json
def changePassword(socket, user, old, new): def changePassword(socket, user, old, new):
if(user.id42 == None): if(user.id42 != None):
socket.sendError("You can't set or change this field if you have a 42 account", 9031) socket.sendError("You can't set or change this field if you have a 42 account", 9031)
return(False) return(False)
if (old == None): if (old == None):

View File

@ -3,10 +3,10 @@
# ::: :::::::: # # ::: :::::::: #
# start.py :+: :+: :+: # # start.py :+: :+: :+: #
# +:+ +:+ +:+ # # +:+ +:+ +:+ #
# By: tomoron <tomoron@student.42.fr> +#+ +:+ +#+ # # By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ # # +#+#+#+#+#+ +#+ #
# Created: 2024/10/04 17:16:02 by tomoron #+# #+# # # Created: 2024/10/04 17:16:02 by tomoron #+# #+# #
# Updated: 2024/10/14 20:25:16 by tomoron ### ########.fr # # Updated: 2024/11/22 23:18:15 by edbernar ### ########.fr #
# # # #
# **************************************************************************** # # **************************************************************************** #
@ -14,22 +14,25 @@ from ...Tournament import Tournament
from ...GameSettings import GameSettings from ...GameSettings import GameSettings
async def tournamentStart(socket, content): async def tournamentStart(socket, content):
skinId = content.get("skinId", 0) try:
if(skinId < 0 or skinId >= GameSettings.nbSkins): skinId = content.get("skinId", 0)
socket.sendError("Skin id out of range", 9033) if(skinId < 0 or skinId >= GameSettings.nbSkins):
return; socket.sendError("Skin id out of range", 9033)
goalId = content.get("goalId",0)
if(goalId < 0 or goalId >= GameSettings.nbGoals):
socket.sendError("Goal id out of range", 9039)
return;
if("code" in content and len(content["code"])):
if(content["code"] in Tournament.currentTournaments):
Tournament.currentTournaments[content["code"]].join(socket, skin, goal)
else:
socket.sync_send("tournament",{"action":0, "exist":False})
else:
nbBot = content.get("nbBot", 0)
if(nbBot < 0 or nbBot > 7):
socket.sendError("invalid number of bots", 9040)
return; return;
Tournament(socket, nbBot, skinId, goalId) goalId = content.get("goalId",0)
if(goalId < 0 or goalId >= GameSettings.nbGoals):
socket.sendError("Goal id out of range", 9039)
return;
if("code" in content and len(content["code"])):
if(content["code"] in Tournament.currentTournaments):
Tournament.currentTournaments[content["code"]].join(socket, skinId, goalId)
else:
socket.sync_send("tournament",{"action":0, "exist":False})
else:
nbBot = content.get("nbBot", 0)
if(nbBot < 0 or nbBot > 7):
socket.sendError("invalid number of bots", 9040)
return;
Tournament(socket, nbBot, skinId, goalId)
except Exception as e:
socket.sendError("error tournament", 9140, e)

View File

@ -6,7 +6,7 @@
# By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ # # By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ # # +#+#+#+#+#+ +#+ #
# Created: 2024/09/09 14:31:30 by tomoron #+# #+# # # Created: 2024/09/09 14:31:30 by tomoron #+# #+# #
# Updated: 2024/11/19 16:52:23 by tomoron ### ########.fr # # Updated: 2024/11/22 22:23:43 by edbernar ### ########.fr #
# # # #
# **************************************************************************** # # **************************************************************************** #
@ -53,7 +53,7 @@ functionRequest = [login, getPrivateListUser, getPrivateListMessage,
from random import randint from random import randint
class WebsocketHandler(AsyncWebsocketConsumer): class WebsocketHandler(AsyncWebsocketConsumer):
debugMode = False debugMode = True
# format : {id : socket, ...} # format : {id : socket, ...}
onlinePlayers = {} onlinePlayers = {}

View File

@ -49,8 +49,8 @@ http {
proxy_read_timeout 86400; proxy_read_timeout 86400;
} }
# location /admin { # location /admin {
# proxy_pass http://adminer:8080; # proxy_pass http://adminer:8080;
# } # }
} }
} }