From 0f072acfd91cf9e63582754245865a3991fec39d Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Wed, 1 Nov 2023 23:14:45 -0400 Subject: [PATCH] fix: Guard undefined ctx.state --- server/routes/app.ts | 2 +- server/utils/passport.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/server/routes/app.ts b/server/routes/app.ts index 1a895a735..23effcb7e 100644 --- a/server/routes/app.ts +++ b/server/routes/app.ts @@ -107,7 +107,7 @@ export const renderApp = async ( }; export const renderShare = async (ctx: Context, next: Next) => { - const rootShareId = ctx.state.rootShare?.id; + const rootShareId = ctx.state?.rootShare?.id; const shareId = rootShareId ?? ctx.params.shareId; const documentSlug = ctx.params.documentSlug; diff --git a/server/utils/passport.ts b/server/utils/passport.ts index bf9836c06..a28eaf35b 100644 --- a/server/utils/passport.ts +++ b/server/utils/passport.ts @@ -116,7 +116,7 @@ export async function getTeamFromContext(ctx: Context) { } else { team = await Team.findOne(); } - } else if (ctx.state.rootShare) { + } else if (ctx.state?.rootShare) { team = await Team.findByPk(ctx.state.rootShare.teamId); } else if (domain.custom) { team = await Team.findOne({ where: { domain: domain.host } });