bug fixed

This commit is contained in:
daniel31x13
2023-11-24 13:28:47 -05:00
parent 87196b1190
commit 676c7c3a5d
4 changed files with 47 additions and 5 deletions
+24 -1
View File
@@ -25,7 +25,30 @@ export default async function Index(req: NextApiRequest, res: NextApiResponse) {
},
});
if (targetUser?.isPrivate) {
if (!targetUser) {
return res
.setHeader("Content-Type", "text/plain")
.status(400)
.send("File inaccessible.");
}
const isInAPublicCollection = await prisma.collection.findFirst({
where: {
["OR"]: [
{ ownerId: targetUser.id },
{
members: {
some: {
userId: targetUser.id,
},
},
},
],
isPublic: true,
},
});
if (targetUser?.isPrivate && !isInAPublicCollection) {
if (!userId) {
return res
.setHeader("Content-Type", "text/plain")