From d38ec06ed6934b7d3adc156968fa25d30e8f6420 Mon Sep 17 00:00:00 2001 From: Sainan <63328889+Sainan@users.noreply.github.com> Date: Mon, 6 Oct 2025 22:54:35 -0700 Subject: [PATCH] fix: disallow creating a clan from an account that's already in one (#2853) Just a slight precaution to avoid snowballing problems. Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/2853 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com> --- src/controllers/api/createGuildController.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/controllers/api/createGuildController.ts b/src/controllers/api/createGuildController.ts index 0db8799b..993774f2 100644 --- a/src/controllers/api/createGuildController.ts +++ b/src/controllers/api/createGuildController.ts @@ -10,6 +10,17 @@ export const createGuildController: RequestHandler = async (req, res) => { const account = await getAccountForRequest(req); const payload = getJSONfromString(String(req.body)); + const inventory = await getInventory(account._id.toString(), "GuildId LevelKeys Recipes"); + if (inventory.GuildId) { + const guild = await Guild.findById(inventory.GuildId); + if (guild) { + res.json({ + ...(await getGuildClient(guild, account)) + }); + return; + } + } + // Remove pending applications for this account await GuildMember.deleteMany({ accountId: account._id, status: 1 }); @@ -27,7 +38,6 @@ export const createGuildController: RequestHandler = async (req, res) => { rank: 0 }); - const inventory = await getInventory(account._id.toString(), "GuildId LevelKeys Recipes"); inventory.GuildId = guild._id; const inventoryChanges: IInventoryChanges = {}; giveClanKey(inventory, inventoryChanges);