Admin page
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
import { define } from "@/utils.ts";
|
||||
import type { MeResponse } from "@/src/admin.ts";
|
||||
import { authenticate, unauthorized } from "@/src/auth.ts";
|
||||
import type { User } from "@/src/db.ts";
|
||||
|
||||
export const handler = define.handlers({
|
||||
async GET(ctx) {
|
||||
const user = await authenticate(ctx.req);
|
||||
if (!user) {
|
||||
return unauthorized();
|
||||
}
|
||||
|
||||
const { name, admin } = user as Partial<User>;
|
||||
return Response.json({ id: user.id, name: name ?? "", admin: admin === true } satisfies MeResponse);
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user