feat: allow anonymous public wishlist viewing
This commit is contained in:
@@ -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 }
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user