feat: allow anonymous public wishlist viewing

This commit is contained in:
Adriano Belisario
2026-05-04 00:09:43 +00:00
parent 6c8e11c851
commit 78bef85c96
6 changed files with 31 additions and 39 deletions

View File

@@ -8,13 +8,9 @@ export async function GET(
{ params }: { params: Promise<{ slug: string }> }
) {
try {
const { slug } = await params;
const isAdmin = verifyAdminToken(request);
const guest = await getGuestFromRequest(request);
if (!isAdmin && !guest) {
return NextResponse.json({ error: 'Convite necessário' }, { status: 401 });
}
const { slug } = await params;
const wishlist = await db
.select()
@@ -29,11 +25,11 @@ export async function GET(
);
}
// Only return public wishlists (admin can see all)
if (!wishlist[0].isPublic && !isAdmin) {
// Public wishlists can be viewed anonymously; private wishlists require admin or guest access.
if (!wishlist[0].isPublic && !isAdmin && !guest) {
return NextResponse.json(
{ error: 'Wishlist not found' },
{ status: 404 }
{ error: 'Convite necessário' },
{ status: 401 }
);
}