mirror of
https://github.com/seanmorley15/AdventureLog.git
synced 2026-01-29 00:40:56 -05:00
Merge pull request #89 from seanmorley15/development
chore: Add authorization check in upload server endpoint
This commit is contained in:
@@ -14,6 +14,15 @@ import { generateId } from "lucia";
|
||||
*/
|
||||
export async function POST(event: RequestEvent): Promise<Response> {
|
||||
try {
|
||||
if (!event.locals.user) {
|
||||
return new Response(JSON.stringify({ error: "Unauthorized" }), {
|
||||
status: 401,
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
const contentType = event.request.headers.get("content-type") ?? "";
|
||||
const fileExtension = contentType.split("/").pop();
|
||||
const fileName = `${generateId(75)}.${fileExtension}`;
|
||||
|
||||
Reference in New Issue
Block a user