[bug] check that users can't see
All checks were successful
Test - Build & Deploy to Scaleway / build-and-push-images-lecoffre (push) Successful in 1m52s
Test - Build & Deploy to Scaleway / deploy-back-lecoffre (push) Successful in 3s
Test - Build & Deploy to Scaleway / deploy-cron-lecoffre (push) Successful in 2s

This commit is contained in:
Sosthene 2025-07-30 19:07:18 +02:00
parent c33d4faacd
commit 71a2c33bf1
3 changed files with 16 additions and 3 deletions

View File

@ -63,8 +63,10 @@ export default class OfficeFoldersController extends ApiController {
}
const userId: string = req.body.user.userId;
const officeId: string = req.body.user.office_Id;
if (query.where?.stakeholders) delete query.where.stakeholders;
const officeFoldersWhereInput: Prisma.OfficeFoldersWhereInput = { ...query.where, stakeholders: { some: { uid: userId } } };
if (query.where?.office_uid) delete query.where.office_uid;
const officeFoldersWhereInput: Prisma.OfficeFoldersWhereInput = { ...query.where, stakeholders: { some: { uid: userId } }, office_uid: officeId };
query.where = officeFoldersWhereInput;
//call service to get prisma entity

View File

@ -60,8 +60,10 @@ export default class OfficeFoldersController extends ApiController {
}
const userId: string = req.body.user.userId;
const officeId: string = req.body.user.office_Id;
if (query.where?.stakeholders) delete query.where.stakeholders;
const officeFoldersWhereInput: Prisma.OfficeFoldersWhereInput = { ...query.where, stakeholders: { some: { uid: userId } } };
if (query.where?.office_uid) delete query.where.office_uid;
const officeFoldersWhereInput: Prisma.OfficeFoldersWhereInput = { ...query.where, stakeholders: { some: { uid: userId } }, office_uid: officeId };
query.where = officeFoldersWhereInput;
//call service to get prisma entity
@ -253,6 +255,7 @@ export default class OfficeFoldersController extends ApiController {
protected async getOneByUid(req: Request, response: Response) {
try {
const uid = req.params["uid"];
const officeId: string = req.body.user.office_Id;
if (!uid) {
this.httpBadRequest(response, "No uid provided");
return;
@ -270,6 +273,12 @@ export default class OfficeFoldersController extends ApiController {
return;
}
// Add office-level validation
if (officeFolderEntity.office_uid !== officeId) {
this.httpUnauthorized(response, "Not authorized to access this folder");
return;
}
//Hydrate ressource with prisma entity
const officeFolder = OfficeFolder.hydrate<OfficeFolder>(officeFolderEntity);

View File

@ -61,8 +61,10 @@ export default class OfficeFoldersController extends ApiController {
}
const userId: string = req.body.user.userId;
const officeId: string = req.body.user.office_Id;
if (query.where?.stakeholders) delete query.where.stakeholders;
const officeFoldersWhereInput: Prisma.OfficeFoldersWhereInput = { ...query.where, stakeholders: { some: { uid: userId } } };
if (query.where?.office_uid) delete query.where.office_uid;
const officeFoldersWhereInput: Prisma.OfficeFoldersWhereInput = { ...query.where, stakeholders: { some: { uid: userId } }, office_uid: officeId };
query.where = officeFoldersWhereInput;
//call service to get prisma entity