Skip to content

Commit 15cd055

Browse files
Sherin-2711i-am-that-guy
authored andcommitted
Added memberId check before deletion and updation of an Interview Experience
1 parent 3cc92a5 commit 15cd055

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

src/controllers/interview.controller.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export const updateInterviewById = async (req: Request, res: Response) => {
8282
}
8383

8484
if (existingInterview.memberId !== memberId) {
85-
throw new ApiError("You are not authorized to update this interview experience", 403);
85+
throw new ApiError("You are not authorized to update this interview experience", 401);
8686
}
8787

8888
const updatedInterview = await interviewService.updateInterviewById(interviewId, {
@@ -103,17 +103,27 @@ export const updateInterviewById = async (req: Request, res: Response) => {
103103

104104
export const deleteInterviewById = async (req: Request, res: Response) => {
105105
const interviewId = parseInt(req.params.id);
106+
const { memberId } = req.body;
106107

107108
if (!interviewId) {
108109
throw new ApiError("Invalid interview ID", 400);
109110
}
110111

112+
if (!memberId) {
113+
throw new ApiError("Member ID is required for verification", 400);
114+
}
115+
111116
const existingInterview = await interviewService.getInterviewById(interviewId);
112117

113118
if (!existingInterview) {
114119
throw new ApiError("Interview experience not found", 404);
115120
}
116121

122+
123+
if (existingInterview.memberId !== memberId) {
124+
throw new ApiError("You are not authorized to delete this interview", 401);
125+
}
126+
117127
await interviewService.deleteInterviewById(interviewId);
118128

119129
res.status(200).json({
@@ -122,4 +132,3 @@ export const deleteInterviewById = async (req: Request, res: Response) => {
122132
});
123133
};
124134

125-

0 commit comments

Comments
 (0)