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
- )} + ):""}
) };