--- import '../../styles.css' import ProfileForm from '../../components/ProfileForm.astro' import { getSession } from '../../lib/session' import { getOAuthClient } from '../../lib/context' import { Agent } from '@atproto/api' const session = getSession(Astro.cookies) const oauthClient = getOAuthClient(Astro.cookies) // Redirect to login if not authenticated if (!session.did) { return Astro.redirect('/') } let agent: Agent | null = null let existingProfile: any = null try { const oauthSession = await oauthClient.restore(session.did) if (oauthSession) { agent = new Agent(oauthSession) // Check if profile already exists try { // Try to get the profile record from the repo const did = agent.assertDid const response = await agent.com.atproto.repo.getRecord({ repo: did, collection: 'org.atmosphereconf.profile', rkey: 'self' }) existingProfile = response.data.value } catch (err) { // Profile doesn't exist yet, which is fine console.log('No existing profile found') } } } catch (err) { console.warn('OAuth restore failed:', err) session.destroy() return Astro.redirect('/') } const displayName = existingProfile?.displayName || '' const description = existingProfile?.description || '' ---