summary refs log tree commit diff
path: root/src/api
diff options
context:
space:
mode:
authorMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2023-04-11 12:33:59 +1000
committerMadeline <46743919+MaddyUnderStars@users.noreply.github.com>2023-04-11 12:33:59 +1000
commit6a148898a511da630ccafd0d47a1854aab9f79a3 (patch)
treec16d6154ab01f5f4ffb7921077e5e2b00d27a97b /src/api
parentprettier (diff)
downloadserver-6a148898a511da630ccafd0d47a1854aab9f79a3.tar.xz
Remove Member.isInGuildOrFail, as it will always pass ( route permission check )
Diffstat (limited to 'src/api')
-rw-r--r--src/api/routes/guilds/#guild_id/roles/#role_id/members.ts10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/api/routes/guilds/#guild_id/roles/#role_id/members.ts b/src/api/routes/guilds/#guild_id/roles/#role_id/members.ts
index a1238382..886b0d1a 100644
--- a/src/api/routes/guilds/#guild_id/roles/#role_id/members.ts
+++ b/src/api/routes/guilds/#guild_id/roles/#role_id/members.ts
@@ -29,11 +29,12 @@ router.patch(
 		// Payload is JSON containing a list of member_ids, the new list of members to have the role
 		const { guild_id, role_id } = req.params;
 		const { member_ids } = req.body;
-		await Member.IsInGuildOrFail(req.user_id, guild_id);
+
 		const members = await Member.find({
 			where: { guild_id },
 			relations: ["roles"],
 		});
+
 		const members_to_add = members.filter((member) => {
 			return (
 				member_ids.includes(member.id) &&
@@ -46,12 +47,15 @@ router.patch(
 				member.roles.map((role) => role.id).includes(role_id)
 			);
 		});
+
 		for (const member of members_to_add) {
-			Member.addRole(member.id, guild_id, role_id);
+			await Member.addRole(member.id, guild_id, role_id);
 		}
+
 		for (const member of members_to_remove) {
-			Member.removeRole(member.id, guild_id, role_id);
+			await Member.removeRole(member.id, guild_id, role_id);
 		}
+
 		res.sendStatus(204);
 	},
 );