fix: disallow creating a clan from an account that's already in one
All checks were successful
Build / build (pull_request) Successful in 4m29s
All checks were successful
Build / build (pull_request) Successful in 4m29s
Just a slight precaution to avoid snowballing problems.
This commit is contained in:
parent
66d3057d40
commit
50c2ab277f
@ -10,6 +10,17 @@ export const createGuildController: RequestHandler = async (req, res) => {
|
|||||||
const account = await getAccountForRequest(req);
|
const account = await getAccountForRequest(req);
|
||||||
const payload = getJSONfromString<ICreateGuildRequest>(String(req.body));
|
const payload = getJSONfromString<ICreateGuildRequest>(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
|
// Remove pending applications for this account
|
||||||
await GuildMember.deleteMany({ accountId: account._id, status: 1 });
|
await GuildMember.deleteMany({ accountId: account._id, status: 1 });
|
||||||
|
|
||||||
@ -27,7 +38,6 @@ export const createGuildController: RequestHandler = async (req, res) => {
|
|||||||
rank: 0
|
rank: 0
|
||||||
});
|
});
|
||||||
|
|
||||||
const inventory = await getInventory(account._id.toString(), "GuildId LevelKeys Recipes");
|
|
||||||
inventory.GuildId = guild._id;
|
inventory.GuildId = guild._id;
|
||||||
const inventoryChanges: IInventoryChanges = {};
|
const inventoryChanges: IInventoryChanges = {};
|
||||||
giveClanKey(inventory, inventoryChanges);
|
giveClanKey(inventory, inventoryChanges);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user