From 2d1f3084f597b01fb2eb35e8a8c98f00fc6745f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Cadenas?= <77900120+andrrsin@users.noreply.github.com> Date: Tue, 26 Mar 2024 11:40:41 +0100 Subject: [PATCH] fix #68 and #69 --- users/authservice/auth-service.js | 2 +- users/userservice/user-service.js | 2 +- webapp/src/components/Game.jsx | 12 +++++------- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/users/authservice/auth-service.js b/users/authservice/auth-service.js index fb2b1bd..c6a21df 100644 --- a/users/authservice/auth-service.js +++ b/users/authservice/auth-service.js @@ -11,7 +11,7 @@ const port = 8002; app.use(express.json()); // Connect to MongoDB -const mongoUri = process.env.MONGODB_URI || 'mongodb://localhost:27017/userdb'; +const mongoUri = process.env.MONGODB_URI || 'mongodb://localhost:27017/wiq-en1a-users'; mongoose.connect(mongoUri); // Function to validate required fields in the request body diff --git a/users/userservice/user-service.js b/users/userservice/user-service.js index bfb7912..85d43c8 100644 --- a/users/userservice/user-service.js +++ b/users/userservice/user-service.js @@ -13,7 +13,7 @@ const port = 8001; app.use(bodyParser.json()); // Connect to MongoDB -const mongoUri = process.env.MONGODB_URI || 'mongodb://localhost:27017/userdb'; +const mongoUri = process.env.MONGODB_URI || 'mongodb://localhost:27017/wiq-en1a-users'; mongoose.connect(mongoUri); diff --git a/webapp/src/components/Game.jsx b/webapp/src/components/Game.jsx index 0572206..e19e95b 100644 --- a/webapp/src/components/Game.jsx +++ b/webapp/src/components/Game.jsx @@ -12,17 +12,15 @@ const Game = () => { const startGame = () => { setGameStarted(!gameStarted); }; - useEffect(() => { - if(isAuthenticated()===false) { - navigate('/login'); + if (!isAuthenticated()) { + navigate("/login"); } - } - , [isAuthenticated]); + }, [isAuthenticated, navigate]); return (
- {gameStarted ? ( + {isAuthenticated()?gameStarted ? ( ) : (
@@ -32,7 +30,7 @@ const Game = () => { Play
- )} + ):""}
) };