Greatly reduce repeated code
This commit is contained in:
@ -1,13 +1,10 @@
|
||||
import { jsonError } from "../../../common.js";
|
||||
|
||||
export async function onRequest(context: RequestContext) {
|
||||
if (
|
||||
![1 << 4, 1 << 12].find((p) => context.data.current_user?.permissions & p)
|
||||
)
|
||||
return new Response('{"error":"Forbidden"}', {
|
||||
headers: {
|
||||
"content-type": "application/json",
|
||||
},
|
||||
status: 403,
|
||||
});
|
||||
return jsonError("Forbidden", 403);
|
||||
|
||||
return await context.next();
|
||||
}
|
||||
|
Reference in New Issue
Block a user