A website for the ATmosphereConf
at init 87 lines 2.8 kB view raw
1--- 2import '../../styles.css' 3import ProfileForm from '../../components/ProfileForm.astro' 4import { getSession } from '../../lib/session' 5import { getOAuthClient } from '../../lib/context' 6import { Agent } from '@atproto/api' 7 8const session = getSession(Astro.cookies) 9const oauthClient = getOAuthClient(Astro.cookies) 10 11// Redirect to login if not authenticated 12if (!session.did) { 13 return Astro.redirect('/') 14} 15 16let agent: Agent | null = null 17let existingProfile: any = null 18 19try { 20 const oauthSession = await oauthClient.restore(session.did) 21 if (oauthSession) { 22 agent = new Agent(oauthSession) 23 24 // Check if profile already exists 25 try { 26 // Try to get the profile record from the repo 27 const did = agent.assertDid 28 const response = await agent.com.atproto.repo.getRecord({ 29 repo: did, 30 collection: 'org.atmosphereconf.profile', 31 rkey: 'self' 32 }) 33 existingProfile = response.data.value 34 } catch (err) { 35 // Profile doesn't exist yet, which is fine 36 console.log('No existing profile found') 37 } 38 } 39} catch (err) { 40 console.warn('OAuth restore failed:', err) 41 session.destroy() 42 return Astro.redirect('/') 43} 44 45const displayName = existingProfile?.displayName || '' 46const description = existingProfile?.description || '' 47--- 48 49<html lang="en" data-theme="dracula"> 50 <head> 51 <meta charset="utf-8" /> 52 <link rel="icon" type="image/svg+xml" href="/favicon.svg" /> 53 <meta name="viewport" content="width=device-width" /> 54 <meta name="generator" content={Astro.generator} /> 55 <title>Create Profile - ATmosphere</title> 56 </head> 57 <body> 58 <div class="min-h-screen flex items-center justify-center p-4"> 59 <div class="card w-full max-w-2xl bg-base-200 shadow-xl"> 60 <div class="card-body"> 61 <h2 class="card-title justify-center text-2xl mb-6"> 62 {existingProfile ? 'Update Your Profile' : 'Create Your Profile'} 63 </h2> 64 65 <div class="alert alert-info mb-4"> 66 <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" class="stroke-current shrink-0 w-6 h-6"> 67 <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path> 68 </svg> 69 <span>Set up your conference attendee profile</span> 70 </div> 71 72 <ProfileForm 73 displayName={displayName} 74 description={description} 75 submitLabel={existingProfile ? 'Update Profile' : 'Create Profile'} 76 /> 77 78 <div class="divider">OR</div> 79 80 <a href="/" class="btn btn-ghost w-full"> 81 Back to Home 82 </a> 83 </div> 84 </div> 85 </div> 86 </body> 87</html>