diff --git a/backend/src/controllers/walkthrough.controller.ts b/backend/src/controllers/walkthrough.controller.ts index aeacd94..d37baf8 100644 --- a/backend/src/controllers/walkthrough.controller.ts +++ b/backend/src/controllers/walkthrough.controller.ts @@ -49,6 +49,15 @@ export const createWalkthrough = async (request: FastifyRequest, reply: FastifyR return reply.code(401).send({ message: 'Unauthorized' }); } + // Verify user exists (handle stale tokens after re-seed) + const userExists = await request.server.prisma.user.findUnique({ + where: { id: userId } + }); + + if (!userExists) { + return reply.code(401).send({ message: 'User not found. Please log in again.' }); + } + try { const walkthrough = await request.server.prisma.dailyWalkthrough.create({ data: { @@ -56,6 +65,7 @@ export const createWalkthrough = async (request: FastifyRequest, reply: FastifyR completedBy: userId, status: 'IN_PROGRESS', }, + include: { user: { select: {