Greatly reduce repeated code
This commit is contained in:
@ -1,11 +1,7 @@
|
||||
import { jsonError } from "../../common.js";
|
||||
|
||||
export async function onRequest(context: RequestContext) {
|
||||
if (!context.data.current_user)
|
||||
return new Response('{"error":"Not logged in"}', {
|
||||
headers: {
|
||||
"content-type": "application/json",
|
||||
},
|
||||
status: 401,
|
||||
});
|
||||
if (!context.data.current_user) return jsonError("Not logged in", 401);
|
||||
|
||||
return await context.next();
|
||||
}
|
||||
|
Reference in New Issue
Block a user