Skip to content

Commit

Permalink
fix: Reject asset uploads in demo mode
Browse files Browse the repository at this point in the history
  • Loading branch information
MohamedBassem committed Mar 26, 2024
1 parent d1e8b00 commit e199112
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions apps/web/app/api/assets/route.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { createContextFromRequest } from "@/server/api/client";
import { TRPCError } from "@trpc/server";

import type { ZUploadResponse } from "@hoarder/trpc/types/uploads";
import { saveAsset } from "@hoarder/shared/assetdb";
import serverConfig from "@hoarder/shared/config";

const SUPPORTED_ASSET_TYPES = new Set(["image/jpeg", "image/png"]);

Expand All @@ -13,6 +15,12 @@ export async function POST(request: Request) {
if (!ctx.user) {
return Response.json({ error: "Unauthorized" }, { status: 401 });
}
if (serverConfig.demoMode) {
throw new TRPCError({
message: "Mutations are not allowed in demo mode",
code: "FORBIDDEN",
});
}
const formData = await request.formData();
const data = formData.get("image");
let buffer;
Expand Down

0 comments on commit e199112

Please sign in to comment.