Skip to content

Commit 58be8e0

Browse files
committed
feat: refactor demo sign-up flow by removing demo-fresh-signup endpoint and handling session checks in fresh-signup component
1 parent e4268eb commit 58be8e0

2 files changed

Lines changed: 30 additions & 66 deletions

File tree

app/pages/auth/fresh-signup.vue

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,36 @@ definePageMeta({ layout: 'auth' })
33
44
useSeoMeta({ robots: 'noindex, nofollow' })
55
6-
onMounted(() => {
7-
// Full browser navigation to the server endpoint. The server checks
8-
// the session, destroys it if it belongs to the demo org, clears
9-
// auth cookies via Set-Cookie headers, and returns a 302 redirect
10-
// to either /auth/sign-up or /dashboard. Using native navigation
11-
// (not $fetch) guarantees the browser processes Set-Cookie headers.
12-
window.location.replace('/api/auth/demo-fresh-signup')
6+
const localePath = useLocalePath()
7+
8+
onMounted(async () => {
9+
try {
10+
// Check if there's an existing session and whether it's a demo org
11+
const { hasSession, isDemo } = await $fetch('/api/auth/demo-check')
12+
13+
if (!hasSession) {
14+
window.location.href = localePath('/auth/sign-up')
15+
return
16+
}
17+
18+
if (isDemo) {
19+
// Sign out using the Better Auth client SDK — the same method
20+
// that works in AppTopBar. This properly handles CSRF tokens,
21+
// cookie clearing, and internal auth state, unlike raw $fetch
22+
// to the sign-out endpoint which bypasses all of that.
23+
await authClient.signOut()
24+
clearNuxtData()
25+
// Hard navigate to fully reset all client-side state
26+
window.location.href = localePath('/auth/sign-up')
27+
}
28+
else {
29+
// Real user with a non-demo account — go to dashboard
30+
window.location.href = localePath('/dashboard')
31+
}
32+
}
33+
catch {
34+
window.location.href = localePath('/auth/sign-up')
35+
}
1336
})
1437
</script>
1538

server/api/auth/demo-fresh-signup.get.ts

Lines changed: 0 additions & 59 deletions
This file was deleted.

0 commit comments

Comments
 (0)