diff --git a/package.json b/package.json index 8076536..a1dfce0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "my-weekly-todo-list", - "version": "1.52.0", + "version": "1.52.1", "description": "A web-based weekly task management application that organizes to-dos and calendar events in a single, intuitive weekly view", "main": "index.js", "scripts": { diff --git a/src/lib/auth.ts b/src/lib/auth.ts index 9d7c243..ba76f28 100644 --- a/src/lib/auth.ts +++ b/src/lib/auth.ts @@ -113,14 +113,18 @@ export const authOptions: NextAuthOptions = { if (user) { token.id = user.id; } - // Refresh user ID from DB to handle stale sessions after DB changes - if (token.email) { - const dbUser = await prisma.user.findUnique({ - where: { email: token.email as string }, - select: { id: true } - }); - if (dbUser) { - token.id = dbUser.id; + // Refresh user ID from DB periodically (not on every request) + if (token.email && !token.id) { + try { + const dbUser = await prisma.user.findUnique({ + where: { email: token.email as string }, + select: { id: true } + }); + if (dbUser) { + token.id = dbUser.id; + } + } catch (e) { + console.error("[AUTH] JWT callback DB lookup failed:", e); } } return token;