Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion app/api/newsletter/route.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { NextRequest, NextResponse } from "next/server";
import { auth } from "@clerk/nextjs/server";
import { PrismaClient } from "@prisma/client";
import { upstashLimit } from "@/lib/rate-limit-upstash";
import { getClientIP } from "@/lib/rate-limit";
Expand Down Expand Up @@ -201,8 +202,14 @@
}

// GET /api/newsletter/stats - Get newsletter statistics (admin only)
export async function GET(request: NextRequest) {
export async function GET(_request: NextRequest) {

Check warning on line 205 in app/api/newsletter/route.ts

View workflow job for this annotation

GitHub Actions / build

'_request' is defined but never used
try {
const { userId } = await auth();

if (!userId) {
return NextResponse.json({ error: "Unauthorized" }, { status: 401 });
}
Comment on lines +213 to +217

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Restrict newsletter stats to admins

For any regular signed-in Clerk user, this check only verifies that auth() returned a userId, so GET /api/newsletter still returns recentSubscribers with subscriber emails/names/sources. Since this handler is marked admin-only and sign-up is public in the app, the sensitive subscriber list remains exposed to all authenticated users unless you also validate an admin role/metadata or move it behind an admin-only route.

Useful? React with 👍 / 👎.


const totalSubscribers = await prisma.newsletterSubscriber.count({
where: { status: "active" },
});
Expand Down
Loading