feat: allow anonymous public wishlist viewing
This commit is contained in:
@@ -11,12 +11,6 @@ export async function GET(
|
||||
try {
|
||||
const { id } = await params;
|
||||
|
||||
const isAdmin = verifyAdminToken(request);
|
||||
const guest = await getGuestFromRequest(request);
|
||||
if (!isAdmin && !guest) {
|
||||
return NextResponse.json({ error: 'Convite necessário' }, { status: 401 });
|
||||
}
|
||||
|
||||
// Check if wishlist exists
|
||||
const wishlist = await db
|
||||
.select()
|
||||
@@ -31,11 +25,14 @@ export async function GET(
|
||||
);
|
||||
}
|
||||
|
||||
// Permissions: guest can only see public wishlists; admin sees all
|
||||
if (!wishlist[0].isPublic && !isAdmin) {
|
||||
const isAdmin = verifyAdminToken(request);
|
||||
const guest = await getGuestFromRequest(request);
|
||||
|
||||
// Public wishlists can be viewed anonymously; private wishlists require admin or guest access.
|
||||
if (!wishlist[0].isPublic && !isAdmin && !guest) {
|
||||
return NextResponse.json(
|
||||
{ error: 'This wishlist is private' },
|
||||
{ status: 403 }
|
||||
{ error: 'Convite necessário' },
|
||||
{ status: 401 }
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user