mirror of
https://github.com/simstudioai/sim.git
synced 2026-09-24 15:45:35 +08:00
fix(auth): Redirect to login if user session doesn't exist (#4497)
* feat(admin): Increase impersonation timeout to 100 years * fix(workspace): redirect to login on missing session instead of leaving blank workspace
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { redirect } from 'next/navigation'
|
||||
import { ToastProvider } from '@/components/emcn'
|
||||
import { getSession } from '@/lib/auth'
|
||||
import { NavTour } from '@/app/workspace/[workspaceId]/components/product-tour'
|
||||
@@ -13,8 +14,11 @@ import { getOrgWhitelabelSettings } from '@/ee/whitelabeling/org-branding'
|
||||
|
||||
export default async function WorkspaceLayout({ children }: { children: React.ReactNode }) {
|
||||
const session = await getSession()
|
||||
if (!session?.user) {
|
||||
redirect('/login')
|
||||
}
|
||||
// The organization plugin is conditionally spread so TS can't infer activeOrganizationId on the base session type.
|
||||
const orgId = (session?.session as { activeOrganizationId?: string } | null)?.activeOrganizationId
|
||||
const orgId = (session.session as { activeOrganizationId?: string } | null)?.activeOrganizationId
|
||||
const initialOrgSettings = orgId ? await getOrgWhitelabelSettings(orgId) : null
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user