From 2036011fdcce1b8acd218031d3cfbcb3e431dc97 Mon Sep 17 00:00:00 2001 From: fullsizemalt <106900403+fullsizemalt@users.noreply.github.com> Date: Fri, 12 Dec 2025 23:10:34 -0800 Subject: [PATCH] fix: handle stale tokens by checking user existence before creating walkthrough --- backend/src/controllers/walkthrough.controller.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) 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: {