Skip to content

Commit

Permalink
fix: correct HTTP status code in case of insufficient user rights
Browse files Browse the repository at this point in the history
  • Loading branch information
drahoja9 committed Aug 20, 2024
1 parent 35b329b commit 93d0c5d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion app/upload/upload/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ export async function POST(request: Request): Promise<Response> {
// Only users with the `assetUpload` feature flag may upload
const user = await getUserProfile(id);
if (!user?.featureFlags.includes("assetUpload")) {
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
return NextResponse.json(
{
error: `Feature flag 'assetUpload' not set for user '${user?.name}'.`,
},
{ status: 403 },
);
}

const body = (await request.json()) as HandleUploadBody;
Expand Down

0 comments on commit 93d0c5d

Please sign in to comment.