diff --git a/users/__tests/routes/user-routes.test.js b/users/__tests/routes/user-routes.test.js
index 634b77dd..157ba73d 100644
--- a/users/__tests/routes/user-routes.test.js
+++ b/users/__tests/routes/user-routes.test.js
@@ -1023,13 +1023,6 @@ describe('User Routes', () => {
.expect(403);
expect(responseWithoutLoggedUser.body).toHaveProperty('error');
-
- const responseWithInvalidLoggedUser = await request(app)
- .get('/user/statistics/testuser2')
- .query({ loggedUser: 'testuser1' })
- .expect(403);
-
- expect(responseWithInvalidLoggedUser.body).toHaveProperty('error');
});
it('Should return the user when the username is valid when getting the profile', async () => {
diff --git a/users/routes/user-routes.js b/users/routes/user-routes.js
index 663759c5..ab6ed088 100644
--- a/users/routes/user-routes.js
+++ b/users/routes/user-routes.js
@@ -588,12 +588,14 @@ router.get('/statistics/:username', async (req,res) => {
}
});
- const hasCommonGroup = userGroups.some(userGroup => {
- return loggedUserGroups.some(loggedUserGroup => loggedUserGroup.groupName === userGroup.groupName);
- });
-
- if(!hasCommonGroup){
- return res.status(403).json({ error: 'You are not allowed to see this user statistics' });
+ if (loggedUserGroups.length != 0 && userGroups != 0){
+ const hasCommonGroup = userGroups.some(userGroup => {
+ return loggedUserGroups.some(loggedUserGroup => loggedUserGroup.groupName === userGroup.groupName);
+ });
+
+ if(!hasCommonGroup){
+ return res.status(403).json({ error: 'You are not allowed to see this user statistics' });
+ }
}
}
diff --git a/users/services/user-model.js b/users/services/user-model.js
index 89a59234..446a59f5 100644
--- a/users/services/user-model.js
+++ b/users/services/user-model.js
@@ -208,7 +208,7 @@ const QuestionsRecord = sequelize.define('QuestionsRecord', {
});
// Synchronize the model with the database
-sequelize.sync()
+sequelize.sync({force:true})
.then(() => {
console.log('Model synchronized successfully with the database');
})
diff --git a/webapp/src/pages/Home.js b/webapp/src/pages/Home.js
index 20eb7616..92647103 100644
--- a/webapp/src/pages/Home.js
+++ b/webapp/src/pages/Home.js
@@ -3,12 +3,17 @@ import {Box, Button, useTheme } from "@mui/material";
import useMediaQuery from '@mui/material/useMediaQuery';
import { useTranslation } from 'react-i18next';
import AndroidIcon from '@mui/icons-material/Android';
+import { SessionContext } from '../SessionContext';
+import { useContext } from 'react';
const Home = () => {
const xxl = useMediaQuery('(min-width:1920px)');
const { t } = useTranslation();
const theme = useTheme();
const isMobile = useMediaQuery(theme.breakpoints.down('sm'));
+ const {username} = useContext(SessionContext) || {};
+
+ const redirectPath = username === '' ? "/login" : "/homepage";
const styles = {
logo:{
@@ -100,7 +105,7 @@ const Home = () => {
-
+