Skip to content

Commit

Permalink
fix: includes endpoint return boolean, and correct status code 200
Browse files Browse the repository at this point in the history
  • Loading branch information
edalholt committed Nov 12, 2023
1 parent 40e4a57 commit 33c7c3e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 11 deletions.
13 changes: 6 additions & 7 deletions backend/controllers/assembly.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ export async function isUserInAssembly(req: RequestWithNtnuiNo, res: Response) {
}
const groupSlug = req.body.groupSlug;
const user = await User.findById(req.ntnuiNo);
let checkedIn = false;

if (user) {
if (user.groups.some((membership) => membership.groupSlug == groupSlug)) {
Expand All @@ -182,14 +183,12 @@ export async function isUserInAssembly(req: RequestWithNtnuiNo, res: Response) {
}

if (assembly.participants.includes(Number(req.ntnuiNo))) {
return res
.status(200)
.json({ status: "ok", info: "User is already checked in" });
} else {
return res
.status(401)
.json({ status: "not checked-in", info: "User is not checked in" });
checkedIn = true;
}

return res
.status(200)
.json({ checkedIn: checkedIn, assembly: assembly._id });
}
}
return res.status(401).json({ message: "Not authorized" });
Expand Down
5 changes: 1 addition & 4 deletions frontend/src/services/assembly.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@ export const isUserInAssembly = async (groupSlug: string): Promise<boolean> => {
const res = await axios.post("/assembly/user/includes", {
groupSlug: groupSlug,
});
if (res.status == 200) {
return true;
}
return false;
return res.data.checkedIn;
};

export const activateAssembly = async (group: string, isActive: boolean) => {
Expand Down

0 comments on commit 33c7c3e

Please sign in to comment.