Skip to content

Commit

Permalink
Merge pull request #127 from Sourav-Tekdi/cohort_member
Browse files Browse the repository at this point in the history
Cohort member update api issue
  • Loading branch information
Shubham4026 authored Jan 6, 2025
2 parents 5b267f1 + da8558d commit 5c8a6ab
Showing 1 changed file with 24 additions and 5 deletions.
29 changes: 24 additions & 5 deletions src/cohortMembers/cohortMembers.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,11 @@ export class CohortMembersController {
public async createCohortMembers(
@Headers() headers,
@Req() request,
@Query('userId') userId: string,
@Body() cohortMembersDto: CohortMembersDto,
@Res() response: Response
) {
const loginUser = request.user.userId;
const loginUser = userId;
const tenantId = headers["tenantid"];
const deviceId = headers["deviceid"];
const academicyearId = headers["academicyearid"];
Expand All @@ -84,6 +85,11 @@ export class CohortMembersController {
"academicyearId is required and academicyearId must be a valid UUID."
);
}
if (!loginUser || !isUUID(loginUser)) {
throw new BadRequestException(
"unauthorized!"
);
}
const result = await this.cohortMemberAdapter
.buildCohortMembersAdapter()
.createCohortMembers(
Expand Down Expand Up @@ -190,15 +196,20 @@ export class CohortMembersController {
@ApiNotFoundResponse({ description: "Data not found" })
@ApiBadRequestResponse({ description: "Bad request" })
@ApiBody({ type: CohortMembersUpdateDto })
@UsePipes(new ValidationPipe())
@UsePipes(new ValidationPipe())
public async updateCohortMembers(
@Param("cohortmembershipid") cohortMembersId: string,
@Req() request,
@Body() cohortMemberUpdateDto: CohortMembersUpdateDto,
@Res() response: Response
@Res() response: Response,
@Query('userId') userId: string
) {
const loginUser = request.user.userId;

const loginUser = userId;
if (!loginUser || !isUUID(loginUser)) {
throw new BadRequestException(
"unauthorized!"
);
}
const result = await this.cohortMemberAdapter
.buildCohortMembersAdapter()
.updateCohortMembers(
Expand Down Expand Up @@ -262,6 +273,14 @@ export class CohortMembersController {
const loginUser = userId;
const tenantId = headers["tenantid"];
const academicyearId = headers["academicyearid"];
if (!loginUser || !isUUID(loginUser)) {
throw new BadRequestException(
"unauthorized!"
);
}
if (!tenantId || !isUUID(tenantId)) {
throw new BadRequestException(API_RESPONSES.TENANTID_VALIDATION);
}
if (!academicyearId || !isUUID(academicyearId)) {
throw new BadRequestException(
"academicyearId is required and must be a valid UUID."
Expand Down

0 comments on commit 5c8a6ab

Please sign in to comment.