Permalink
Newer
100644
21 lines (18 sloc)
513 Bytes
1
export async function onRequest(context: RequestContext) {
2
const { current_user: currentUser } = context.data;
3
4
if (!currentUser)
5
return new Response('{"error":Not logged in"}', {
6
headers: {
7
"content-type": "application/json",
8
},
9
status: 401,
10
});
11
12
if (!(currentUser.permissions & (1 << 5)))
13
return new Response('{"error":"Forbidden"}', {
14
headers: {
15
"content-type": "application/json",
16
},
17
status: 403,
18
});
19
20
return await context.next();
21
}