File uploading
This commit is contained in:
+14
@@ -0,0 +1,14 @@
|
||||
import { db } from "./db.ts";
|
||||
|
||||
// Reads the user's code from an "Authorization: Bearer <code>" header
|
||||
export async function authenticate(req: Request) {
|
||||
const code = req.headers.get("Authorization")?.match(/^Bearer (\S+)$/)?.[1];
|
||||
if (!code) {
|
||||
return undefined;
|
||||
}
|
||||
return await db.get_entry_by_index("users", "code", code);
|
||||
}
|
||||
|
||||
export function unauthorized() {
|
||||
return Response.json({ error: "Invalid code" }, { status: 401 });
|
||||
}
|
||||
Reference in New Issue
Block a user