Fix invitee access to shared logbooks by listing collaborated logbooks in API and saving them locally on accept

This commit is contained in:
2026-05-28 21:42:47 +02:00
parent 9d24f4b71a
commit b62ca14cc1
2 changed files with 30 additions and 2 deletions
+16 -2
View File
@@ -15,11 +15,25 @@ const requireUser = (req: any, res: any, next: any) => {
router.use(requireUser)
// 1. Get all logbooks for the authenticated user
// 1. Get all logbooks for the authenticated user (owned and shared)
router.get('/', async (req: any, res) => {
try {
const logbooks = await prisma.logbook.findMany({
where: { userId: req.userId },
where: {
OR: [
{ userId: req.userId },
{
collaborators: {
some: { userId: req.userId }
}
}
]
},
include: {
collaborators: {
where: { userId: req.userId }
}
},
orderBy: { createdAt: 'desc' }
})
return res.json(logbooks)