diff --git a/containers/api/src/app.controller.ts b/containers/api/src/app.controller.ts index 73e38d2e..ccd9bc25 100644 --- a/containers/api/src/app.controller.ts +++ b/containers/api/src/app.controller.ts @@ -6,7 +6,7 @@ /* By: apommier +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/06/17 01:00:00 by apommier #+# #+# */ -/* Updated: 2023/06/28 13:57:06 by apommier ### ########.fr */ +/* Updated: 2023/06/28 16:50:11 by apommier ### ########.fr */ /* */ /* ************************************************************************** */ @@ -54,9 +54,7 @@ export class AppController { if(!user) return ; if (user.sessionNumber === 1) - { user.status = 0; - } user.sessionNumber--; this.userService.save(user); } @@ -210,7 +208,8 @@ export class AppController { @Post('/rmGame') async removeGame(@Request() req, @Body() data: any) { const user = await this.userService.findOne(req.user.username); - user.gameSession -= 1; + if (user.gameSession > 0) + user.gameSession -= 1; if (user.gameSession === 0) user.status = 1; await this.userService.save(user); @@ -303,7 +302,8 @@ export class AppController { const user = await this.userService.findOne(req.user.username); if (!user) return ; - user.sessionNumber--; + if (user.sessionNumber > 0) + user.sessionNumber--; console.log("seesion number=", user.sessionNumber) if (!user.sessionNumber) user.status = 0; diff --git a/containers/react/.env b/containers/react/.env index 7c5716f6..dff6b578 100644 --- a/containers/react/.env +++ b/containers/react/.env @@ -1,6 +1,6 @@ -REACT_APP_BASE_URL=paul-f4Ar4s3:8080 -REACT_APP_SOCKET_URL=paul-f4Ar4s3 +REACT_APP_BASE_URL=paul-f5Ar4s4:8080 +REACT_APP_SOCKET_URL=paul-f5Ar4s4 REACT_APP_API_SECRET=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 REACT_APP_CLIENT_UID=u-s4t2ud-2bd3c5d4f41e776f2e3d5d699d2a8421f6d0c0468ec882516d9ca89b0c211789 @@ -8,7 +8,7 @@ REACT_APP_CLIENT_UID=u-s4t2ud-2bd3c5d4f41e776f2e3d5d699d2a8421f6d0c0468ec882516d # REACT_APP_BASE_URL=92.143.191.152 # REACT_APP_BASE_URL=192.168.1.19 -REACT_APP_INTRA_URL="https://api.intra.42.fr/oauth/authorize?client_id=u-s4t2ud-2bd3c5d4f41e776f2e3d5d699d2a8421f6d0c0468ec882516d9ca89b0c211789&redirect_uri=http%3A%2F%2Fpaul-f4Ar4s3%3A8080%2Fapi%2Fauth%2Flogin&response_type=code" +REACT_APP_INTRA_URL="https://api.intra.42.fr/oauth/authorize?client_id=u-s4t2ud-2bd3c5d4f41e776f2e3d5d699d2a8421f6d0c0468ec882516d9ca89b0c211789&redirect_uri=http%3A%2F%2Fpaul-f5Ar4s4%3A8080%2Fapi%2Fauth%2Flogin&response_type=code" # REACT_APP_BASE_URL=92.143.191.152 # REACT_APP_BASE_URL=192.168.1.19 diff --git a/containers/react/src/components/App.tsx b/containers/react/src/components/App.tsx index dcbaf3ae..a35a8992 100644 --- a/containers/react/src/components/App.tsx +++ b/containers/react/src/components/App.tsx @@ -48,11 +48,13 @@ function AnimatedRoute() { handleLoad(); window.addEventListener("beforeunload", async (event) => { + if (!localStorage.getItem('token')) + return; await api.post("/quit"); }); - window.addEventListener("unload", async (event) => { - await api.post("/quit"); - }); + // window.addEventListener("unload", async (event) => { + // await api.post("/quit"); + // }); return () => { diff --git a/containers/react/src/components/Messages/Modal.tsx b/containers/react/src/components/Messages/Modal.tsx index 6480f24b..4ffa4877 100644 --- a/containers/react/src/components/Messages/Modal.tsx +++ b/containers/react/src/components/Messages/Modal.tsx @@ -86,8 +86,7 @@ const Modal = ({handleClose}: ModalProps) => { const ret = await api.post("/verifyPassword", {convId: channel, password: PassWord}) if (ret) console.log("ici ret password", ret); - - // window.location.reload(); + // window.location.reload(); } catch (err) { console.log(err); } @@ -115,7 +114,7 @@ const Modal = ({handleClose}: ModalProps) => { console.log("ici test channel= ", channel) await api.post("/join", {convId: channel}) - window.location.reload(); + // window.location.reload(); } catch(err) { console.log(err); } diff --git a/docker-compose.yml b/docker-compose.yml index c22f5d90..3432cdc0 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -63,7 +63,7 @@ services: - 5432:5432 volumes: - db:/var/lib/postgresql/data - - ./conf/init.sql:/docker-entrypoint-initdb.d/create_tables.sql + # - ./conf/init.sql:/docker-entrypoint-initdb.d/create_tables.sql networks: - pongNetwork