Skip to content

Commit

Permalink
Merge branch 'dev' into GameFrontEnd
Browse files Browse the repository at this point in the history
  • Loading branch information
pelazas committed Mar 11, 2024
2 parents fe51abf + e2e0529 commit 47694f8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
4 changes: 3 additions & 1 deletion gatewayservice/gateway-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ app.post('/login', async (req, res) => {
try {
// Forward the login request to the authentication service
const authResponse = await axios.post(authServiceUrl+'/login', req.body);
res.json(authResponse.data);
const username = authResponse.data.username;
const userResponse = await axios.get(userServiceUrl+'/getUser/' + username);
res.json(userResponse.data);
} catch (error) {
res.status(error.response.status).json({ error: error.response.data.error });
}
Expand Down
5 changes: 5 additions & 0 deletions users/userservice/UserController.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,11 @@ let UserController = {
const uuid = req.params.id;
const user = await User.findOne({ uuid: uuid }).select('-password');
res.json(user);
},
getUserByUsername: async (req, res) => {
const username = req.params.username;
const user = await User.findOne({ username: username }).select('-password');
res.json(user);
}

}
Expand Down
1 change: 1 addition & 0 deletions users/userservice/user-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ app.post('/adduser',UserController.addUser);
app.post('/updateLastGame', UserController.updateLastGame);
app.post('/updateStatistics', UserController.updateStatistics);
app.get('/getStatistics/:id', UserController.getStatistics);
app.get('/getUser/:username', UserController.getUserByUsername)

const server = app.listen(port, () => {
console.log(`User Service listening at http://localhost:${port}`);
Expand Down

0 comments on commit 47694f8

Please sign in to comment.