[bug] check that users can't see
All checks were successful
All checks were successful
This commit is contained in:
parent
c33d4faacd
commit
71a2c33bf1
@ -63,8 +63,10 @@ export default class OfficeFoldersController extends ApiController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const userId: string = req.body.user.userId;
|
const userId: string = req.body.user.userId;
|
||||||
|
const officeId: string = req.body.user.office_Id;
|
||||||
if (query.where?.stakeholders) delete query.where.stakeholders;
|
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;
|
query.where = officeFoldersWhereInput;
|
||||||
|
|
||||||
//call service to get prisma entity
|
//call service to get prisma entity
|
||||||
|
@ -60,8 +60,10 @@ export default class OfficeFoldersController extends ApiController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const userId: string = req.body.user.userId;
|
const userId: string = req.body.user.userId;
|
||||||
|
const officeId: string = req.body.user.office_Id;
|
||||||
if (query.where?.stakeholders) delete query.where.stakeholders;
|
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;
|
query.where = officeFoldersWhereInput;
|
||||||
|
|
||||||
//call service to get prisma entity
|
//call service to get prisma entity
|
||||||
@ -253,6 +255,7 @@ export default class OfficeFoldersController extends ApiController {
|
|||||||
protected async getOneByUid(req: Request, response: Response) {
|
protected async getOneByUid(req: Request, response: Response) {
|
||||||
try {
|
try {
|
||||||
const uid = req.params["uid"];
|
const uid = req.params["uid"];
|
||||||
|
const officeId: string = req.body.user.office_Id;
|
||||||
if (!uid) {
|
if (!uid) {
|
||||||
this.httpBadRequest(response, "No uid provided");
|
this.httpBadRequest(response, "No uid provided");
|
||||||
return;
|
return;
|
||||||
@ -270,6 +273,12 @@ export default class OfficeFoldersController extends ApiController {
|
|||||||
return;
|
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
|
//Hydrate ressource with prisma entity
|
||||||
const officeFolder = OfficeFolder.hydrate<OfficeFolder>(officeFolderEntity);
|
const officeFolder = OfficeFolder.hydrate<OfficeFolder>(officeFolderEntity);
|
||||||
|
|
||||||
|
@ -61,8 +61,10 @@ export default class OfficeFoldersController extends ApiController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const userId: string = req.body.user.userId;
|
const userId: string = req.body.user.userId;
|
||||||
|
const officeId: string = req.body.user.office_Id;
|
||||||
if (query.where?.stakeholders) delete query.where.stakeholders;
|
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;
|
query.where = officeFoldersWhereInput;
|
||||||
|
|
||||||
//call service to get prisma entity
|
//call service to get prisma entity
|
||||||
|
Loading…
x
Reference in New Issue
Block a user