Skip to content
This repository was archived by the owner on Jan 22, 2026. It is now read-only.

Commit 5622fe8

Browse files
committed
Fix project endpoint that need :entityId instead of :id (#350)
1 parent f9b98b4 commit 5622fe8

File tree

3 files changed

+15
-14
lines changed

3 files changed

+15
-14
lines changed

server/api/project/index.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ router.get('/', auth.isAuthenticated(), controller.index);
6565
* '404':
6666
* description: Project not found
6767
*/
68-
router.get('/:id', auth.hasPermissionForEntity([
68+
router.get('/:entityId', auth.hasPermissionForEntity([
6969
READ_ACCESS,
7070
WRITE_ACCESS,
7171
ADMIN_ACCESS
@@ -125,7 +125,7 @@ router.post('/', auth.isAuthenticated(), controller.create);
125125
* '404':
126126
* description: Project not found
127127
*/
128-
router.patch('/:id', auth.hasPermissionForEntity([
128+
router.patch('/:entityId', auth.hasPermissionForEntity([
129129
ADMIN_ACCESS
130130
]), controller.patch);
131131

@@ -138,16 +138,16 @@ router.patch('/:id', auth.hasPermissionForEntity([
138138
* summary: Returns the visibility of the project.
139139
* description: Returns the visibility of the project.
140140
* produces:
141-
* - application/json
141+
* - text/plain
142142
* responses:
143143
* '200':
144144
* description: The visibility of the project
145145
* content:
146-
* application/json:
146+
* text/plain:
147147
* schema:
148148
* $ref: '#/components/schemas/EntityVisibility'
149149
*/
150-
router.get('/:id/visibility', controller.showVisibility);
150+
router.get('/:id/visibility', auth.isAuthenticated(), controller.showVisibility);
151151

152152
/**
153153
* @swagger

server/api/project/project.controller.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export function index(req, res) {
3131

3232
// Gets a single Project from the DB
3333
export function show(req, res) {
34-
return Project.findById(req.params.id)
34+
return Project.findById(req.params.entityId)
3535
.exec()
3636
.then(handleEntityNotFound(res))
3737
.then(respondWithResult(res))
@@ -53,7 +53,7 @@ export function create(req, res) {
5353
export function patch(req, res) {
5454
const patches = req.body.filter(patch => !['_id', 'createdAt', 'createdBy'].map(x => `/${x}`).includes(patch.path));
5555

56-
return Project.findById(req.params.id)
56+
return Project.findById(req.params.entityId)
5757
.exec()
5858
.then(handleEntityNotFound(res))
5959
.then(patchUpdates(patches))
@@ -62,13 +62,13 @@ export function patch(req, res) {
6262
}
6363

6464
// Deletes a Project from the DB
65-
export function destroy(req, res) {
66-
return Project.findById(req.params.id)
67-
.exec()
68-
.then(handleEntityNotFound(res))
69-
.then(removeEntity(res))
70-
.catch(handleError(res));
71-
}
65+
// export function destroy(req, res) {
66+
// return Project.findById(req.params.id)
67+
// .exec()
68+
// .then(handleEntityNotFound(res))
69+
// .then(removeEntity(res))
70+
// .catch(handleError(res));
71+
// }
7272

7373
// Returns whether a project is public or private
7474
export function showVisibility(req, res) {

server/auth/auth.service.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ export function isAuthorizedForEntity(allowedAccesses) {
8686
return compose().use((req, res, next) =>
8787
_hasAccessToEntity(req.user._id, allowedAccesses, req.params.entityId)
8888
.then(accessGranted => {
89+
console.log('_hasAccessToEntity OUTPUT', accessGranted);
8990
if (accessGranted) return next();
9091
return null;
9192
})

0 commit comments

Comments
 (0)