Skip to content

Commit d5615b7

Browse files
authored
Merge pull request #1922 from bcgov/fix/signatories-permission
Fix/signatories permission
2 parents 4593342 + 98526f6 commit d5615b7

File tree

4 files changed

+47
-5
lines changed

4 files changed

+47
-5
lines changed

backend/src/components/permissionUtils.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,25 @@ async function checkUserAccessToDuplicateSdcSchoolCollections(req, res, next) {
511511
return next();
512512
}
513513

514+
async function checkDistrictBelongsInSdcDistrictCollection(req, res, next) {
515+
if (!res.locals.requestedSdcDistrictCollection) {
516+
return res.status(HttpStatus.BAD_REQUEST).json({
517+
message: 'SdcDistrictCollectionID is required.'
518+
});
519+
}
520+
if (!res.locals.requestedInstituteIdentifier) {
521+
return res.status(HttpStatus.BAD_REQUEST).json({
522+
message: 'DistrictID is required.'
523+
});
524+
}
525+
if(res.locals.requestedSdcDistrictCollection.districtID !== res.locals.requestedInstituteIdentifier) {
526+
return res.status(HttpStatus.FORBIDDEN).json({
527+
message: 'District does not belong to this sdc district collection.'
528+
});
529+
}
530+
return next();
531+
}
532+
514533
const permUtils = {
515534
checkEDXUserAccessToRequestedInstitute,
516535
checkEdxUserPermission,
@@ -557,7 +576,8 @@ const permUtils = {
557576
findSchoolContactId_params,
558577
findSdcSchoolCollectionsInDuplicate,
559578
checkSdcDuplicateAccess,
560-
checkUserAccessToDuplicateSdcSchoolCollections
579+
checkUserAccessToDuplicateSdcSchoolCollections,
580+
checkDistrictBelongsInSdcDistrictCollection
561581
};
562582

563583
module.exports = permUtils;

backend/src/routes/sdc.js

Lines changed: 5 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

backend/src/validations/sdc.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,20 @@ const postStartFromPriorCollectionSchema = object({
396396
query: object(),
397397
}).unknown();
398398

399+
const getSdcDistrictUsersSchema = object({
400+
body: object().noUnknown(),
401+
params: object({
402+
sdcDistrictCollectionID: string().nonNullable()
403+
}),
404+
query: object({
405+
digitalId: string().nullable().optional(),
406+
schoolID: string().nullable().optional(),
407+
firstName: string().nullable().optional(),
408+
lastName: string().nullable().optional(),
409+
districtID: string().nullable().optional()
410+
}).noUnknown(),
411+
}).noUnknown();
412+
399413

400414
module.exports = {
401415
putSdcStudentSchema,
@@ -422,5 +436,6 @@ module.exports = {
422436
schoolFileCollectionSchema: postSchoolFileCollectionSchema,
423437
resolveDuplicateSchema: postResolveDuplicateSchema,
424438
markDiffSchema: postMarKDiffSchema,
425-
startFromPriorCollectionSchema: postStartFromPriorCollectionSchema
439+
startFromPriorCollectionSchema: postStartFromPriorCollectionSchema,
440+
getSdcDistrictUsersSchema
426441
};

frontend/src/components/common/SignOffSignatures.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ export default {
179179
180180
async getUsersData() {
181181
const payload = {params: {districtID: this.districtCollection.districtID}};
182-
await ApiService.apiAxios.get(ApiRoutes.edx.USERS_URL, payload)
182+
await ApiService.apiAxios.get(ApiRoutes.sdc.SDC_DISTRICT_COLLECTION + '/' + this.districtCollection.sdcDistrictCollectionID + '/users', payload)
183183
.then(response => {
184184
this.users = response.data;
185185
let signatures = this.districtCollection.submissionSignatures;
@@ -198,6 +198,10 @@ export default {
198198
});
199199
}
200200
}
201+
})
202+
.catch(error => {
203+
console.error(error);
204+
setFailureAlert('An error occurred while attempting to load sign-off details. Please try again later.');
201205
});
202206
},
203207
mapRoletext(role) {

0 commit comments

Comments
 (0)