Create direct game bans middleware
This commit is contained in:
parent
32387f9c2a
commit
4687540269
21
functions/api/game-bans/_middleware.ts
Normal file
21
functions/api/game-bans/_middleware.ts
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
export async function onRequest(context: RequestContext) {
|
||||||
|
const { current_user: currentUser } = context.data;
|
||||||
|
|
||||||
|
if (!currentUser)
|
||||||
|
return new Response('{"error":Not logged in"}', {
|
||||||
|
headers: {
|
||||||
|
"content-type": "application/json",
|
||||||
|
},
|
||||||
|
status: 401,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!(currentUser.permissions & (1 << 5)))
|
||||||
|
return new Response('{"error":"Forbidden"}', {
|
||||||
|
headers: {
|
||||||
|
"content-type": "application/json",
|
||||||
|
},
|
||||||
|
status: 403,
|
||||||
|
});
|
||||||
|
|
||||||
|
return await context.next();
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user