diff --git a/backend/apis/nodejs/src/app.js b/backend/apis/nodejs/src/app.js index fe42dea..bd3e456 100644 --- a/backend/apis/nodejs/src/app.js +++ b/backend/apis/nodejs/src/app.js @@ -24,7 +24,7 @@ const personRoutes = require('./routes/person_routes.js'); const organizationRoutes = require('./routes/organization_routes.js'); const organizationAdminRoutes = require('./routes/organization_admin_routes.js'); const organizationPostRoutes = require('./routes/organization_post_routes.js'); -const jwt_utils = require('./utils/middleware_utils.js'); +const jwtUtils = require('./utils/middleware_utils.js'); /* ===== END IMPORTING MODULES @@ -54,17 +54,17 @@ app.use(rateLimit({ const publicRoutes = express.Router(); publicRoutes.post('/register', personRoutes.registerPerson); publicRoutes.post('/login', personRoutes.login); +publicRoutes.get('/person/:id/details', personRoutes.getPerson); +publicRoutes.get('/organization/:id', organizationRoutes.getOrganization); const protectedRoutes = express.Router(); -protectedRoutes.use(jwt_utils.verifyToken); +protectedRoutes.use(jwtUtils.verifyToken); protectedRoutes.get('/person/myself', personRoutes.getMyself); -protectedRoutes.get('/person/:id', personRoutes.getPerson); protectedRoutes.put('/person/:id', personRoutes.updatePerson); protectedRoutes.delete('/person/delete', personRoutes.deletePerson); protectedRoutes.post('/organization/admin', organizationAdminRoutes.addOrganizationAdmin); protectedRoutes.delete('/organization/removeadmin', organizationAdminRoutes.removeOrganizationAdmin); protectedRoutes.post('/organization', organizationRoutes.createOrganization); -protectedRoutes.get('/organization/:id', organizationRoutes.getOrganization); protectedRoutes.put('/organization/:id', organizationRoutes.updateOrganization); protectedRoutes.delete('/organization/:id', organizationRoutes.deleteOrganization); protectedRoutes.post('/organization/post', organizationPostRoutes.createOrganizationPost); diff --git a/backend/apis/nodejs/src/routes/person_routes.js b/backend/apis/nodejs/src/routes/person_routes.js index 93605b8..0b982af 100644 --- a/backend/apis/nodejs/src/routes/person_routes.js +++ b/backend/apis/nodejs/src/routes/person_routes.js @@ -108,12 +108,9 @@ async function login (req, res) { async function getPerson (req, res) { try { const person = await personModel.getPersonById(req.params.id); - if (person) { - // I am retrieving either myself or an enabled user - if (person.id == req.jwt.person_id || person.enabled) { - delete person.password; // remove password field for security reasons - return res.status(200).send(person); - } + if (person && person.enabled) { + delete person.password; // remove password field for security reasons + return res.status(200).send(person); } return res.status(404).json({ error: 'Not found' }); } catch (error) { diff --git a/frontend/vanilla/html/organization.html b/frontend/vanilla/html/organization.html index ab2e288..0ece3ec 100644 --- a/frontend/vanilla/html/organization.html +++ b/frontend/vanilla/html/organization.html @@ -6,15 +6,15 @@
Location:
+Location:
Email:
Hiring: