Skip to content

Commit

Permalink
fix(meetings): Add aurhorization checking
Browse files Browse the repository at this point in the history
  • Loading branch information
HagerDakroury committed Jul 15, 2021
1 parent ae4a68e commit 08e9e9c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions meetings/src/routes/end.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ router.post(`${baseUrl}/end/:id`, async (req: Request, res: Response) => {
}

const user = resV.data._id;
const role = resV.data.role;

if (role != "instructor") {
return res.status(400).send("Only instructors can end meetings!");
}

if (!id.match(/^[0-9a-fA-F]{24}$/)) {
return res.status(400).send("Meeting is not found");
Expand Down
6 changes: 6 additions & 0 deletions meetings/src/routes/new.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ router.post(
return res.status(400).send("User is not authorized");
}

const role = resV.data.role;

if (role != "instructor") {
return res.status(400).send("Only instructors can create meetings!");
}

const { title, course, startTime, endTime } = req.body;
const status = "incoming";
const host = resV.data._id;
Expand Down
5 changes: 5 additions & 0 deletions meetings/src/routes/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ router.post(`${baseUrl}/start/:id`, async (req: Request, res: Response) => {
return res.status(400).send("User is not authorized");
}
const user = resV.data._id;
const role = resV.data.role;

if (role != "instructor") {
return res.status(400).send("Only instructors can start meetings!");
}

if (!id.match(/^[0-9a-fA-F]{24}$/)) {
return res.status(400).send("Meeting is not found");
Expand Down

0 comments on commit 08e9e9c

Please sign in to comment.