diff --git a/ui/src/pages/OnboardingPage.tsx b/ui/src/pages/OnboardingPage.tsx index 930165c..8337228 100644 --- a/ui/src/pages/OnboardingPage.tsx +++ b/ui/src/pages/OnboardingPage.tsx @@ -1,4 +1,5 @@ import { useState, useEffect, useRef } from 'react'; +import { useLogto } from '@logto/react'; import { Card, Input, Button, FormField, Alert } from '@cameleer/design-system'; import cameleerLogo from '@cameleer/design-system/assets/cameleer-logo.svg'; import { api } from '../api/client'; @@ -13,6 +14,7 @@ interface TenantResponse { } export function OnboardingPage() { + const { signIn } = useLogto(); const [name, setName] = useState(''); const [loading, setLoading] = useState(false); const [error, setError] = useState(null); @@ -48,9 +50,11 @@ export function OnboardingPage() { setLoading(true); try { await api.post('/onboarding/tenant', { name, slug }); - // Tenant created — force a full page reload so the Logto SDK - // picks up the new org membership and scopes on the next token refresh. - window.location.href = '/platform/'; + // Tenant created — force a fresh OIDC sign-in so the Logto SDK gets + // new tokens that include the org membership just created. The existing + // Logto session cookie means the user won't see a login form — Logto + // auto-approves and redirects back with fresh tokens. + await signIn(`${window.location.origin}/platform/callback`); } catch (err) { const msg = err instanceof Error ? err.message : String(err); if (msg.includes('409')) {