fix: handle stale tokens by checking user existence before creating walkthrough
Some checks are pending
Deploy to Production / deploy (push) Waiting to run
Test / backend-test (push) Waiting to run
Test / frontend-test (push) Waiting to run

This commit is contained in:
fullsizemalt 2025-12-12 23:10:34 -08:00
parent 36dbeb23c3
commit 2036011fdc

View file

@ -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: {