Skip to content

Commit f81eba9

Browse files
fix(workspace): redirect to login on missing session instead of leaving blank workspace
1 parent 9d4bf16 commit f81eba9

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

apps/sim/app/workspace/[workspaceId]/layout.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { redirect } from 'next/navigation'
12
import { ToastProvider } from '@/components/emcn'
23
import { getSession } from '@/lib/auth'
34
import { NavTour } from '@/app/workspace/[workspaceId]/components/product-tour'
@@ -13,8 +14,11 @@ import { getOrgWhitelabelSettings } from '@/ee/whitelabeling/org-branding'
1314

1415
export default async function WorkspaceLayout({ children }: { children: React.ReactNode }) {
1516
const session = await getSession()
17+
if (!session?.user) {
18+
redirect('/login')
19+
}
1620
// The organization plugin is conditionally spread so TS can't infer activeOrganizationId on the base session type.
17-
const orgId = (session?.session as { activeOrganizationId?: string } | null)?.activeOrganizationId
21+
const orgId = (session.session as { activeOrganizationId?: string } | null)?.activeOrganizationId
1822
const initialOrgSettings = orgId ? await getOrgWhitelabelSettings(orgId) : null
1923

2024
return (

apps/sim/lib/auth/auth.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -861,9 +861,7 @@ export const auth = betterAuth({
861861
}),
862862
]
863863
: []),
864-
admin({
865-
impersonationSessionDuration: 60 * 60 * 24 * 365 * 100,
866-
}),
864+
admin(),
867865
jwt({
868866
jwks: {
869867
keyPairConfig: { alg: 'RS256' },

0 commit comments

Comments
 (0)