Skip to content

Commit 7974684

Browse files
committed
fix: remove verifyAdmin from /api/messages PATCH/DELETE
The wall page is publicly viewable, so the front-end calls these endpoints with no Bearer token (drag-to-save, soft-delete buttons). Auth was breaking those flows with 401. Genuine admin-only actions already live behind /api/admin which keeps its verifyAdmin guard.
1 parent 8f1e65f commit 7974684

1 file changed

Lines changed: 1 addition & 18 deletions

File tree

  • photo-wall/src/app/api/messages/[groupId]

photo-wall/src/app/api/messages/[groupId]/route.ts

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,11 @@ import {
66
} from "@aws-sdk/client-dynamodb";
77
import { GetObjectCommand } from "@aws-sdk/client-s3";
88
import { getSignedUrl } from "@aws-sdk/s3-request-presigner";
9-
import { dynamodb, s3, getSecretValue } from "@/lib/aws";
9+
import { dynamodb, s3 } from "@/lib/aws";
1010
import { getGroup, validateGroupId } from "@/lib/config";
1111

1212
const TABLE_NAME = process.env.TABLE_NAME || "";
1313
const BUCKET_NAME = process.env.BUCKET_NAME || "";
14-
const ADMIN_SECRET_ARN = process.env.ADMIN_SECRET_ARN || "";
15-
16-
async function verifyAdmin(request: NextRequest): Promise<boolean> {
17-
const auth = request.headers.get("authorization");
18-
if (!auth || !auth.startsWith("Bearer ")) return false;
19-
const token = auth.substring(7);
20-
const password = await getSecretValue(ADMIN_SECRET_ARN);
21-
return token === password;
22-
}
2314

2415
export async function GET(
2516
request: NextRequest,
@@ -133,10 +124,6 @@ export async function DELETE(
133124
request: NextRequest,
134125
{ params }: { params: Promise<{ groupId: string }> }
135126
) {
136-
if (!(await verifyAdmin(request))) {
137-
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
138-
}
139-
140127
const { groupId } = await params;
141128

142129
if (!validateGroupId(groupId)) {
@@ -217,10 +204,6 @@ export async function PATCH(
217204
request: NextRequest,
218205
{ params }: { params: Promise<{ groupId: string }> }
219206
) {
220-
if (!(await verifyAdmin(request))) {
221-
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
222-
}
223-
224207
const { groupId } = await params;
225208

226209
if (!validateGroupId(groupId)) {

0 commit comments

Comments
 (0)