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' });
|
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 {
|
try {
|
||||||
const walkthrough = await request.server.prisma.dailyWalkthrough.create({
|
const walkthrough = await request.server.prisma.dailyWalkthrough.create({
|
||||||
data: {
|
data: {
|
||||||
|
|
@ -56,6 +65,7 @@ export const createWalkthrough = async (request: FastifyRequest, reply: FastifyR
|
||||||
completedBy: userId,
|
completedBy: userId,
|
||||||
status: 'IN_PROGRESS',
|
status: 'IN_PROGRESS',
|
||||||
},
|
},
|
||||||
|
|
||||||
include: {
|
include: {
|
||||||
user: {
|
user: {
|
||||||
select: {
|
select: {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue