返回提交历史
Modified
src/controllers/api/createGuildController.ts
+11
-1
XFEstudio/XFESpaceNinjaServer
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>
d38ec06e
代码差异
1 个文件
+11
-1
@@ -10,6 +10,17 @@ export const createGuildController: RequestHandler = async (req, res) => {
10
10
const account = await getAccountForRequest(req);
11
11
const payload = getJSONfromString<ICreateGuildRequest>(String(req.body));
12
12
13
const inventory = await getInventory(account._id.toString(), "GuildId LevelKeys Recipes");
14
if (inventory.GuildId) {
15
const guild = await Guild.findById(inventory.GuildId);
16
if (guild) {
17
res.json({
18
...(await getGuildClient(guild, account))
19
});
20
return;
21
}
22
}
23
13
24
// Remove pending applications for this account
14
25
await GuildMember.deleteMany({ accountId: account._id, status: 1 });
15
26
@@ -27,7 +38,6 @@ export const createGuildController: RequestHandler = async (req, res) => {
27
38
rank: 0
28
39
});
29
40
30
const inventory = await getInventory(account._id.toString(), "GuildId LevelKeys Recipes");
31
41
inventory.GuildId = guild._id;
32
42
const inventoryChanges: IInventoryChanges = {};
33
43
giveClanKey(inventory, inventoryChanges);