Compare commits

...

2 Commits

Author SHA1 Message Date
e73c6e40eb check permission for pausing & unpausing research
All checks were successful
Build / build (18) (push) Successful in 47s
Build / build (18) (pull_request) Successful in 46s
Build / build (22) (push) Successful in 1m7s
Build / build (22) (pull_request) Successful in 42s
Build / build (20) (push) Successful in 1m6s
Build / build (20) (pull_request) Successful in 1m6s
2025-03-14 15:26:01 +01:00
a7f9832310 fix permission check for starting research 2025-03-14 15:25:49 +01:00

View File

@ -54,7 +54,7 @@ export const guildTechController: RequestHandler = async (req, res) => {
} }
res.json({ TechProjects: techProjects }); res.json({ TechProjects: techProjects });
} else if (data.Action == "Start") { } else if (data.Action == "Start") {
if (!hasAccessToDojo(inventory) || !(await hasGuildPermission(guild, accountId, GuildPermission.Fabricator))) { if (!hasAccessToDojo(inventory) || !(await hasGuildPermission(guild, accountId, GuildPermission.Tech))) {
res.status(400).send("-1").end(); res.status(400).send("-1").end();
return; return;
} }
@ -193,6 +193,10 @@ export const guildTechController: RequestHandler = async (req, res) => {
// Not a mistake: This response uses `inventoryChanges` instead of `InventoryChanges`. // Not a mistake: This response uses `inventoryChanges` instead of `InventoryChanges`.
res.json({ inventoryChanges: inventoryChanges }); res.json({ inventoryChanges: inventoryChanges });
} else if (data.Action == "Pause") { } else if (data.Action == "Pause") {
if (!hasAccessToDojo(inventory) || !(await hasGuildPermission(guild, accountId, GuildPermission.Tech))) {
res.status(400).send("-1").end();
return;
}
const project = guild.TechProjects!.find(x => x.ItemType == data.RecipeType)!; const project = guild.TechProjects!.find(x => x.ItemType == data.RecipeType)!;
project.State = -2; project.State = -2;
guild.ActiveDojoColorResearch = ""; guild.ActiveDojoColorResearch = "";
@ -200,6 +204,10 @@ export const guildTechController: RequestHandler = async (req, res) => {
await removePigmentsFromGuildMembers(guild._id); await removePigmentsFromGuildMembers(guild._id);
res.end(); res.end();
} else if (data.Action == "Unpause") { } else if (data.Action == "Unpause") {
if (!hasAccessToDojo(inventory) || !(await hasGuildPermission(guild, accountId, GuildPermission.Tech))) {
res.status(400).send("-1").end();
return;
}
const project = guild.TechProjects!.find(x => x.ItemType == data.RecipeType)!; const project = guild.TechProjects!.find(x => x.ItemType == data.RecipeType)!;
project.State = 0; project.State = 0;
guild.ActiveDojoColorResearch = data.RecipeType; guild.ActiveDojoColorResearch = data.RecipeType;