fix: handle stale tokens by checking user existence before creating walkthrough
This commit is contained in:
parent
36dbeb23c3
commit
2036011fdc
1 changed files with 10 additions and 0 deletions
|
|
@ -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: {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue