Greatly reduce repeated code
This commit is contained in:
@ -1,3 +1,5 @@
|
||||
import { jsonError } from "../../common.js";
|
||||
|
||||
export async function onRequest(context: RequestContext) {
|
||||
const { current_user: currentUser } = context.data;
|
||||
|
||||
@ -9,12 +11,7 @@ export async function onRequest(context: RequestContext) {
|
||||
"396347223736057866",
|
||||
].includes(currentUser.id)
|
||||
)
|
||||
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