返回提交历史
Modified
src/controllers/custom/addVaultDecoRecipeController.ts
+3
-3
Modified
src/controllers/custom/setGuildCheatController.ts
+3
-3
Modified
src/controllers/custom/techProjectController.ts
+8
-9
Modified
static/webui/script.js
+0
-26
XFEstudio/SpaceNinjaServer
chore(webui): adjust checks for guild view requests (#2807)
Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/2807 Reviewed-by: Sainan <63328889+sainan@users.noreply.github.com> Co-authored-by: AMelonInsideLemon <166175391+AMelonInsideLemon@users.noreply.github.com> Co-committed-by: AMelonInsideLemon <166175391+AMelonInsideLemon@users.noreply.github.com>
86a63ace
代码差异
4 个文件
+14
-41
@@ -1,16 +1,16 @@
1
1
import { getAccountIdForRequest } from "../../services/loginService.ts";
2
2
import { getInventory } from "../../services/inventoryService.ts";
3
3
import type { RequestHandler } from "express";
4
import { hasAccessToDojo, getGuildForRequestEx, hasGuildPermission } from "../../services/guildService.ts";
4
import { getGuildForRequestEx, hasGuildPermission } from "../../services/guildService.ts";
5
5
import { GuildPermission } from "../../types/guildTypes.ts";
6
6
import type { ITypeCount } from "../../types/commonTypes.ts";
7
7
8
8
export const addVaultDecoRecipeController: RequestHandler = async (req, res) => {
9
9
const accountId = await getAccountIdForRequest(req);
10
10
const requests = req.body as ITypeCount[];
11
const inventory = await getInventory(accountId, "LevelKeys GuildId");
11
const inventory = await getInventory(accountId, "GuildId");
12
12
const guild = await getGuildForRequestEx(req, inventory);
13
if (!hasAccessToDojo(inventory) || !(await hasGuildPermission(guild, accountId, GuildPermission.Architect))) {
13
if (!(await hasGuildPermission(guild, accountId, GuildPermission.Architect))) {
14
14
res.status(400).send("-1").end();
15
15
return;
16
16
}
@@ -1,5 +1,5 @@
1
1
import { GuildMember } from "../../models/guildModel.ts";
2
import { getGuildForRequestEx, hasAccessToDojo } from "../../services/guildService.ts";
2
import { getGuildForRequestEx } from "../../services/guildService.ts";
3
3
import { getInventory } from "../../services/inventoryService.ts";
4
4
import { getAccountIdForRequest } from "../../services/loginService.ts";
5
5
import type { IGuildCheats } from "../../types/guildTypes.ts";
@@ -8,12 +8,12 @@ import type { RequestHandler } from "express";
8
8
export const setGuildCheatController: RequestHandler = async (req, res) => {
9
9
const accountId = await getAccountIdForRequest(req);
10
10
const payload = req.body as ISetGuildCheatRequest;
11
const inventory = await getInventory(accountId, `${payload.key} GuildId LevelKeys`);
11
const inventory = await getInventory(accountId, `GuildId`);
12
12
const guild = await getGuildForRequestEx(req, inventory);
13
13
const member = await GuildMember.findOne({ accountId: accountId, guildId: guild._id });
14
14
15
15
if (member) {
16
if (!hasAccessToDojo(inventory) || member.rank > 1) {
16
if (member.rank > 1) {
17
17
res.end();
18
18
return;
19
19
}
@@ -2,7 +2,6 @@ import { getAccountIdForRequest } from "../../services/loginService.ts";
2
2
import { getInventory } from "../../services/inventoryService.ts";
3
3
import type { RequestHandler } from "express";
4
4
import {
5
hasAccessToDojo,
6
5
getGuildForRequestEx,
7
6
setGuildTechLogState,
8
7
processFundedGuildTechProject,
@@ -19,9 +18,9 @@ import { GuildMember } from "../../models/guildModel.ts";
19
18
export const addTechProjectController: RequestHandler = async (req, res) => {
20
19
const accountId = await getAccountIdForRequest(req);
21
20
const requests = req.body as ITechProjectRequest[];
22
const inventory = await getInventory(accountId, "LevelKeys GuildId");
21
const inventory = await getInventory(accountId, "GuildId");
23
22
const guild = await getGuildForRequestEx(req, inventory);
24
if (!hasAccessToDojo(inventory) || !(await hasGuildPermission(guild, accountId, GuildPermission.Tech))) {
23
if (!(await hasGuildPermission(guild, accountId, GuildPermission.Tech))) {
25
24
res.status(400).send("-1").end();
26
25
return;
27
26
}
@@ -54,9 +53,9 @@ export const addTechProjectController: RequestHandler = async (req, res) => {
54
53
export const removeTechProjectController: RequestHandler = async (req, res) => {
55
54
const accountId = await getAccountIdForRequest(req);
56
55
const requests = req.body as ITechProjectRequest[];
57
const inventory = await getInventory(accountId, "LevelKeys GuildId");
56
const inventory = await getInventory(accountId, "GuildId");
58
57
const guild = await getGuildForRequestEx(req, inventory);
59
if (!hasAccessToDojo(inventory) || !(await hasGuildPermission(guild, accountId, GuildPermission.Tech))) {
58
if (!(await hasGuildPermission(guild, accountId, GuildPermission.Tech))) {
60
59
res.status(400).send("-1").end();
61
60
return;
62
61
}
@@ -74,13 +73,13 @@ export const removeTechProjectController: RequestHandler = async (req, res) => {
74
73
export const fundTechProjectController: RequestHandler = async (req, res) => {
75
74
const accountId = await getAccountIdForRequest(req);
76
75
const requests = req.body as ITechProjectRequest[];
77
const inventory = await getInventory(accountId, "LevelKeys GuildId");
76
const inventory = await getInventory(accountId, "GuildId");
78
77
const guild = await getGuildForRequestEx(req, inventory);
79
78
const guildMember = (await GuildMember.findOne(
80
79
{ accountId, guildId: guild._id },
81
80
"RegularCreditsContributed MiscItemsContributed"
82
81
))!;
83
if (!hasAccessToDojo(inventory)) {
82
if (!(await hasGuildPermission(guild, accountId, GuildPermission.Tech))) {
84
83
res.status(400).send("-1").end();
85
84
return;
86
85
}
@@ -105,9 +104,9 @@ export const fundTechProjectController: RequestHandler = async (req, res) => {
105
104
export const completeTechProjectsController: RequestHandler = async (req, res) => {
106
105
const accountId = await getAccountIdForRequest(req);
107
106
const requests = req.body as ITechProjectRequest[];
108
const inventory = await getInventory(accountId, "LevelKeys GuildId");
107
const inventory = await getInventory(accountId, "GuildId");
109
108
const guild = await getGuildForRequestEx(req, inventory);
110
if (!hasAccessToDojo(inventory)) {
109
if (!(await hasGuildPermission(guild, accountId, GuildPermission.Tech))) {
111
110
res.status(400).send("-1").end();
112
111
return;
113
112
}
@@ -1992,32 +1992,6 @@ function updateInventory() {
1992
1992
});
1993
1993
}
1994
1994
1995
function addVaultDecoRecipe() {
1996
const uniqueName = getKey(document.getElementById("acquire-type-VaultDecoRecipes"));
1997
if (!guildId) {
1998
return;
1999
}
2000
if (!uniqueName) {
2001
$("acquire-type-VaultDecoRecipes").addClass("is-invalid").focus();
2002
return;
2003
}
2004
revalidateAuthz().then(() => {
2005
const req = $.post({
2006
url: "/custom/addVaultDecoRecipe?" + window.authz + "&guildId=" + window.guildId,
2007
contentType: "application/json",
2008
data: JSON.stringify([
2009
{
2010
ItemType: uniqueName,
2011
ItemCount: 1
2012
}
2013
])
2014
});
2015
req.done(() => {
2016
updateInventory();
2017
});
2018
});
2019
}
2020
2021
1995
function changeGuildRank(guildId, targetId, rankChange) {
2022
1996
revalidateAuthz().then(() => {
2023
1997
const req = $.get(