Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Task #215826 Task #215928 Addition of AclGuard permissions to the modules #938

Open
wants to merge 17 commits into
base: feat-acl
Choose a base branch
from
Open
4 changes: 3 additions & 1 deletion src/src/beneficiaries/beneficiaries.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ export class BeneficiariesController {

@Post('/admin/list/duplicates-by-aadhaar')
@UseGuards(AuthGuard)
@UseGuards(AclGuard)
@AclGuardData('beneficiary', ['read', 'read.own'])
async getBeneficiariesDuplicatesByAadhaar(
@Body() body: Record<string, any>,
@Query() query: any,
Expand Down Expand Up @@ -418,7 +420,7 @@ export class BeneficiariesController {
@Post('admin/reassign')
@UseGuards(AuthGuard)
@UseGuards(AclGuard)
@AclGuardData('beneficiary', ['reassign', 'reassign.own'])
@AclGuardData('beneficiary', ['reassign.facilitator.own'])
async reassignBeneficiary(
@Req() request: any,
@Body() body: any,
Expand Down
85 changes: 52 additions & 33 deletions src/src/camp/camp.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,11 @@ export class CampController {
response,
);
}

@Post('/consent/create')
@UseGuards(AuthGuard)
// @UseGuards(RoleGuard)
// @Roles('facilitator')
@UseGuards(AclGuard)
@AclGuardData('consent', ['create'])
createConsentBenficiaries(
@Req() request: any,
@Body() body: any,
Expand All @@ -108,8 +109,8 @@ export class CampController {

@Post('/admin/consent/create')
@UseGuards(AuthGuard)
// @UseGuards(RoleGuard)
// @Roles('staff', 'program_owner')
@UseGuards(AclGuard)
@AclGuardData('consent', ['create'])
adminCreateConsentBenficiaries(
@Req() request: any,
@Body() body: any,
Expand All @@ -124,8 +125,8 @@ export class CampController {

@Post('/consent/get')
@UseGuards(AuthGuard)
// @UseGuards(RoleGuard)
// @Roles('facilitator')
@UseGuards(AclGuard)
@AclGuardData('consent', ['read', 'read.own'])
getConsentBenficiaries(
@Req() request: any,
@Body() body: any,
Expand All @@ -140,8 +141,8 @@ export class CampController {

@Post('/admin/consent/get')
@UseGuards(AuthGuard)
// @UseGuards(RoleGuard)
// @Roles('staff', 'program_owner')
@UseGuards(AclGuard)
@AclGuardData('consent', ['read', 'read.own'])
getAdminConsentBenficiaries(
@Req() request: any,
@Body() body: any,
Expand All @@ -156,8 +157,8 @@ export class CampController {

@Patch('admin/:id')
@UseGuards(AuthGuard)
// @UseGuards(RoleGuard)
// @Roles('staff', 'program_owner')
@UseGuards(AclGuard)
@AclGuardData('camp', ['edit', 'edit.own'])
updateCampStatus(
@Param('id') id: string,
@Body() body: Record<string, any>,
Expand All @@ -169,16 +170,16 @@ export class CampController {

@Post('admin/camp-list')
@UseGuards(AuthGuard)
// @UseGuards(RoleGuard)
// @Roles('staff', 'program_owner')
@UseGuards(AclGuard)
@AclGuardData('camp', ['read', 'read.own'])
getCampList(@Req() req: any, @Res() response: any, @Body() body: any) {
return this.campService.getCampList(body, req, response);
}

@Get('admin/camp-details/:id')
@UseGuards(AuthGuard)
// @UseGuards(RoleGuard)
// @Roles('staff', 'program_owner')
@UseGuards(AclGuard)
@AclGuardData('camp', ['read', 'read.own'])
getCampDetailsForAdmin(
@Param('id') id: number,
@Req() req: any,
Expand All @@ -189,8 +190,8 @@ export class CampController {

@Post('attendance/add')
@UseGuards(AuthGuard)
// @UseGuards(RoleGuard)
// @Roles('facilitator')
@UseGuards(AclGuard)
@AclGuardData('attendance', ['create'])
markCampAttendance(
@Req() req: any,
@Res() response: any,
Expand All @@ -201,8 +202,8 @@ export class CampController {

@Patch('attendance/update/:id')
@UseGuards(AuthGuard)
// @UseGuards(RoleGuard)
// @Roles('facilitator')
@UseGuards(AclGuard)
@AclGuardData('attendance', ['edit.own'])
updateCampAttendance(
@Req() req: any,
@Res() response: any,
Expand All @@ -214,8 +215,8 @@ export class CampController {

@Post('/attendances/list')
@UseGuards(AuthGuard)
// @UseGuards(RoleGuard)
// @Roles('facilitator')
@UseGuards(AclGuard)
@AclGuardData('attendance', ['read.own'])
getAttendanceList(
@Req() req: any,
@Res() response: any,
Expand All @@ -226,8 +227,8 @@ export class CampController {

@Post('attendance/:id')
@UseGuards(AuthGuard)
// @UseGuards(RoleGuard)
// @Roles('facilitator')
@UseGuards(AclGuard)
@AclGuardData('attendance', ['read.own'])
getCampAttendanceById(
@Req() req: any,
@Res() response: any,
Expand All @@ -239,8 +240,8 @@ export class CampController {

@Get('/getStatuswiseCount')
@UseGuards(AuthGuard)
// @UseGuards(RoleGuard)
// @Roles('facilitator')
@UseGuards(AclGuard)
@AclGuardData('camp', ['read.own'])
getStatuswiseCount(
@Body() body: any,
@Req() request: any,
Expand All @@ -252,8 +253,8 @@ export class CampController {
@Post('/admin/filter-by-camps')
@UseGuards(AuthGuard)
@UsePipes(ValidationPipe)
// @UseGuards(RoleGuard)
// @Roles('staff', 'program_owner')
@UseGuards(AclGuard)
@AclGuardData('camp', ['read', 'read.own'])
YoginiTayade marked this conversation as resolved.
Show resolved Hide resolved
async getFilter_By_Camps(
@Req() req: any,
@Res() response: any,
Expand All @@ -264,9 +265,9 @@ export class CampController {

@Patch('/admin/reassign/:id')
@UseGuards(AuthGuard)
// @UseGuards(RoleGuard)
// @Roles('staff', 'program_owner')
reassignBeneficiarytoCamp(
@UseGuards(AclGuard)
@AclGuardData('camp', ['reassign.beneficiary.own'])
async reassignBeneficiarytoCamp(
@Req() request: any,
@Body() body: any,
@Param('id') id: number,
Expand All @@ -282,8 +283,8 @@ export class CampController {

@Post('/admin/facilitators')
@UseGuards(AuthGuard)
// @UseGuards(RoleGuard)
// @Roles('staff', 'program_owner')
@UseGuards(AclGuard)
@AclGuardData('camp', ['read', 'read.own'])
getAvailableFacilitatorList(
@Body() body: any,
@Req() request: any,
Expand All @@ -298,8 +299,8 @@ export class CampController {

@Patch('/admin/facilitator-reassign/:id')
@UseGuards(AuthGuard)
// @UseGuards(RoleGuard)
// @Roles('staff', 'program_owner')
@UseGuards(AclGuard)
@AclGuardData('facilitator', ['reassign.camp.own'])
reassignFaciltatorToCamp(
@Req() request: any,
@Body() body: any,
Expand All @@ -316,6 +317,8 @@ export class CampController {

@Post('/add/campdayactivity')
@UseGuards(AuthGuard)
@UseGuards(AclGuard)
@AclGuardData('camp-day-activity', ['create'])
createCampDayActivity(
@Req() request: any,
@Body() body: any,
Expand All @@ -326,6 +329,8 @@ export class CampController {

@Patch('/camp-day-activity/:id')
@UseGuards(AuthGuard)
// @UseGuards(AclGuard)
// @AclGuardData('camp-day-activity', ['edit.own'])
update_camp_day_activity(
@Req() request: any,
@Body() body: any,
Expand All @@ -342,6 +347,8 @@ export class CampController {

@Post('/camp-day-activity/:id')
@UseGuards(AuthGuard)
@UseGuards(AclGuard)
@AclGuardData('camp', ['read', 'read.own'])
getCampDayActivityById(
@Param('id') id: number,
@Req() request: any,
Expand All @@ -358,12 +365,16 @@ export class CampController {

@Get('/:id/get-camp-sessions')
@UseGuards(AuthGuard)
@UseGuards(AclGuard)
@AclGuardData('camp', ['read', 'read.own'])
getCampSession(@Req() req: any, @Param('id') id: number, @Res() res) {
return this.campService.getCampSessions(req, id, res);
}

@Post('/incomplete/camp-day-activity/:id')
@UseGuards(AuthGuard)
@UseGuards(AclGuard)
@AclGuardData('camp', ['read', 'read.own'])
getPreviousCampAcitivityById(
@Param('id') id: number,
@Req() request: any,
Expand All @@ -380,6 +391,8 @@ export class CampController {

@Get('/random-attendance/:id')
@UseGuards(AuthGuard)
@UseGuards(AclGuard)
@AclGuardData('camp', ['read.own'])
getRandomAttendanceGeneration(
@Param('id') id: number,
@Req() request: any,
Expand All @@ -396,6 +409,8 @@ export class CampController {

@Post('/:id/camp_learners')
@UseGuards(AuthGuard)
@UseGuards(AclGuard)
@AclGuardData('camp', ['read', 'read.own'])
campLearnersById(
@Req() request: any,
@Body() body: any,
Expand All @@ -408,6 +423,8 @@ export class CampController {
//multiple reassigne learner from One camp to other
@Patch('/admin/multiplereassign/:id')
@UseGuards(AuthGuard)
@UseGuards(AclGuard)
@AclGuardData('camp', ['reassign.beneficiary.own'])
multiplereassignBeneficiarytoCamp(
@Req() request: any,
@Body() body: any,
Expand All @@ -424,6 +441,8 @@ export class CampController {

@Post('campday/campdetails')
@UseGuards(AuthGuard)
@UseGuards(AclGuard)
@AclGuardData('camp', ['read.own'])
campDetails(@Req() request: any, @Body() body: any, @Res() response: any) {
return this.campService.campDetails(body, request, response);
}
Expand Down
3 changes: 2 additions & 1 deletion src/src/camp/camp.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2031,7 +2031,8 @@ export class CampService {
}
}
}`;

console.log(query);

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider removing the console.log statement for production readiness.

- console.log(query);

This logging statement could potentially expose sensitive query details in production logs, which might include user data or other sensitive information. It's generally a good practice to remove or replace such logging with more secure logging mechanisms before deploying to production.


Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
console.log(query);

const hasura_response = await this.hasuraServiceFromServices.getData({
query: query,
});
Expand Down
Loading