fix: error when session expired

This commit is contained in:
Carl-Gerhard Lindesvärd
2025-11-01 12:35:23 +01:00
parent 4d7f3e4473
commit c67f7f9578
3 changed files with 5 additions and 14 deletions

View File

@@ -95,7 +95,8 @@ const enforceUserIsAuthed = t.middleware(async ({ ctx, next }) => {
// Only used on protected routes
const enforceAccess = t.middleware(async ({ ctx, next, type, getRawInput }) => {
return runWithAlsSession(ctx.session.session?.id, async () => {
const sessionId = ctx.session?.session?.id ?? null;
return runWithAlsSession(sessionId, async () => {
const rawInput = await getRawInput();
if (type === 'mutation' && process.env.DEMO_USER_ID) {
throw new TRPCError({
@@ -153,7 +154,7 @@ const loggerMiddleware = t.middleware(
);
const sessionScopeMiddleware = t.middleware(async ({ ctx, next }) => {
const sessionId = ctx.session.session?.id ?? null;
const sessionId = ctx.session?.session?.id ?? null;
return runWithAlsSession(sessionId, async () => {
return next();
});