1
0
mirror of https://github.com/spacebarchat/server.git synced 2024-09-22 10:41:34 +02:00

🔒 Fix parent id checking

This commit is contained in:
stefan080106 2021-04-26 21:16:29 +02:00
parent 40e86e43a4
commit 17e52f812c

View File

@ -31,8 +31,9 @@ router.post("/", check(ChannelModifySchema), async (req, res) => {
}
if (body.parent_id) {
const exists = ChannelModel.findOne({ channel_id: body.parent_id }).exec();
const exists = await ChannelModel.findOne({ id: body.parent_id }, {guild_id:true}).exec();
if (!exists) throw new HTTPError("Parent id channel doesn't exist", 400);
if (exists.guild_id !== guild_id) throw new HTTPError("The category channel needs to be in the guild")
}
const guild = await GuildModel.findOne({ id: guild_id }, { id: true }).exec();