Create server handler for mod queue page
This commit is contained in:
parent
7f1deea157
commit
d9a9a9f335
@ -4,9 +4,23 @@ export async function onBeforeRender(pageContext: PageContext) {
|
|||||||
if (!currentUser)
|
if (!currentUser)
|
||||||
return {
|
return {
|
||||||
pageContext: {
|
pageContext: {
|
||||||
|
pageProps: {
|
||||||
logged_in: false,
|
logged_in: false,
|
||||||
},
|
},
|
||||||
status: 401,
|
status: 401,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const newItemPermissions = {
|
||||||
|
game_ban: [1 << 5],
|
||||||
|
inactivity: [1 << 2, 1 << 9, 1 << 10],
|
||||||
|
infraction: [1 << 0, 1 << 2, 1 << 6, 1 << 7]
|
||||||
|
};
|
||||||
|
|
||||||
|
const newItemNames: { [k: string]: string } = {
|
||||||
|
game_ban: "Game Ban",
|
||||||
|
inactivity: "Inactivity Notice",
|
||||||
|
infraction: "Infraction",
|
||||||
};
|
};
|
||||||
|
|
||||||
const typePermissions = {
|
const typePermissions = {
|
||||||
@ -21,8 +35,14 @@ export async function onBeforeRender(pageContext: PageContext) {
|
|||||||
report: "Game Reports",
|
report: "Game Reports",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const allowedNewItems = [];
|
||||||
const allowedTypes = [];
|
const allowedTypes = [];
|
||||||
|
|
||||||
|
for (const [item, ints] of Object.entries(newItemPermissions)) {
|
||||||
|
if (ints.find((i) => currentUser.permissions & i))
|
||||||
|
allowedNewItems.push({ name: newItemNames[item], value: item })
|
||||||
|
}
|
||||||
|
|
||||||
for (const [type, ints] of Object.entries(typePermissions)) {
|
for (const [type, ints] of Object.entries(typePermissions)) {
|
||||||
if (ints.find((i) => currentUser.permissions & i))
|
if (ints.find((i) => currentUser.permissions & i))
|
||||||
allowedTypes.push({ name: typeNames[type], value: type });
|
allowedTypes.push({ name: typeNames[type], value: type });
|
||||||
@ -31,15 +51,21 @@ export async function onBeforeRender(pageContext: PageContext) {
|
|||||||
if (!allowedTypes.length)
|
if (!allowedTypes.length)
|
||||||
return {
|
return {
|
||||||
pageContext: {
|
pageContext: {
|
||||||
|
pageProps: {
|
||||||
entry_types: [],
|
entry_types: [],
|
||||||
|
item_types: [],
|
||||||
|
logged_in: true,
|
||||||
},
|
},
|
||||||
status: 403,
|
status: 403,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
pageContext: {
|
pageContext: {
|
||||||
pageProps: {
|
pageProps: {
|
||||||
entry_types: allowedTypes,
|
entry_types: allowedTypes,
|
||||||
|
item_types: allowedNewItems,
|
||||||
|
logged_in: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user