Return 403 if user cannot see any queue item type
This commit is contained in:
parent
5a9c663479
commit
5d90d0b1b1
@ -1,4 +1,14 @@
|
|||||||
export async function onBeforeRender(pageContext: PageContext) {
|
export async function onBeforeRender(pageContext: PageContext) {
|
||||||
|
const { current_user: currentUser } = pageContext;
|
||||||
|
|
||||||
|
if (!currentUser)
|
||||||
|
return {
|
||||||
|
pageContext: {
|
||||||
|
logged_in: false,
|
||||||
|
},
|
||||||
|
status: 401,
|
||||||
|
};
|
||||||
|
|
||||||
const typePermissions = {
|
const typePermissions = {
|
||||||
appeal: [1 << 0, 1 << 1],
|
appeal: [1 << 0, 1 << 1],
|
||||||
gma: [1 << 5],
|
gma: [1 << 5],
|
||||||
@ -8,13 +18,30 @@ export async function onBeforeRender(pageContext: PageContext) {
|
|||||||
pageContext.urlOriginal,
|
pageContext.urlOriginal,
|
||||||
"http://localhost:8788"
|
"http://localhost:8788"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const allowedTypes = [];
|
||||||
|
|
||||||
|
for (const [type, ints] of Object.entries(typePermissions)) {
|
||||||
|
if (ints.find((i) => currentUser.permissions & i)) allowedTypes.push(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!allowedTypes.length)
|
||||||
|
return {
|
||||||
|
pageContext: {
|
||||||
|
allowedTypes,
|
||||||
|
},
|
||||||
|
status: 403,
|
||||||
|
};
|
||||||
|
|
||||||
const includeClosed = searchParams.get("includeClosed");
|
const includeClosed = searchParams.get("includeClosed");
|
||||||
const type = searchParams.get("type");
|
const type = searchParams.get("type");
|
||||||
const sort = searchParams.get("sort") ?? "asc";
|
const sort = searchParams.get("sort") ?? "asc";
|
||||||
|
|
||||||
return {
|
return {
|
||||||
pageContext: {
|
pageContext: {
|
||||||
pageProps: {},
|
pageProps: {
|
||||||
|
allowedTypes,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user