948948</template>
949949
950950<script>
951- import { authClient } from '~/lib/auth-client '
951+ import { completePublicAuthHandoffFromUrl, fetchPublicAuthSession } from '~/lib/public- auth-handoff '
952952
953953const ROADMAP_PREFETCH_CACHE_TTL_MS = 60_000
954954const FEEDBACK_DETAILS_PREFETCH_CACHE_TTL_MS = 30_000
@@ -1170,7 +1170,7 @@ export default {
11701170 await this.$nextTick()
11711171 this.setupScrollObserver()
11721172 this.warmRoadmapData()
1173- this.checkAdminStatus()
1173+ await this.checkAdminStatus()
11741174 return
11751175 }
11761176 try {
@@ -1179,7 +1179,7 @@ export default {
11791179 this.applyTheme(this.projectData?.project?.settings?.themeMode || 'system')
11801180 await this.loadFeedback()
11811181 this.warmRoadmapData()
1182- this.checkAdminStatus()
1182+ await this.checkAdminStatus()
11831183 } catch (err) {
11841184 console.error('Error loading project:', err)
11851185 this.error = 'This feedback page could not be found.'
@@ -1606,16 +1606,31 @@ export default {
16061606 },
16071607 async checkAdminStatus() {
16081608 if (!import.meta.client) return
1609+
1610+ const handoffCompleted = await completePublicAuthHandoffFromUrl().catch(() => false)
1611+
16091612 try {
1610- const sessionResult = await authClient.getSession()
1611- if (!sessionResult?.data?.user) return
1612- this.currentUser = sessionResult.data.user
1613- this.submitForm.authorName = sessionResult.data.user.name || ''
1614- this.submitForm.authorEmail = sessionResult.data.user.email || ''
1613+ const sessionResult = await fetchPublicAuthSession()
1614+ const currentUser = sessionResult?.user || null
1615+
1616+ this.currentUser = currentUser
1617+ this.isAdmin = false
1618+ this.submitForm.authorName = currentUser?.name || ''
1619+ this.submitForm.authorEmail = currentUser?.email || ''
1620+
1621+ if (!currentUser) {
1622+ return
1623+ }
1624+
1625+ if (handoffCompleted) {
1626+ await $fetch('/api/auth/merge-anonymous', { method: 'POST' }).catch(() => {})
1627+ }
1628+
16151629 const response = await $fetch('/api/teams/list-user')
16161630 const teams = response?.data || []
16171631 this.isAdmin = teams.some((t) => t.slug === this.teamSlug)
16181632 } catch {
1633+ this.currentUser = null
16191634 this.isAdmin = false
16201635 }
16211636 },
0 commit comments