Skip to content

Commit c327cee

Browse files
committed
(feat) added auth callbacks for clerk
Clerk is the auth solution we use, added auth callbacks and simple auth config
1 parent ad4422b commit c327cee

2 files changed

Lines changed: 40 additions & 0 deletions

File tree

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<template>
2+
<div class="flex flex-col items-center justify-center h-screen gap-4">
3+
<div class="size-8 border-4 border-gray-300 border-t-gray-600 rounded-full animate-spin" />
4+
<p class="text-sm text-gray-500">Signing you in...</p>
5+
</div>
6+
</template>
7+
8+
<script setup lang="ts">
9+
const { isSignedIn, getToken } = useAuth()
10+
11+
onMounted(() => {
12+
watch(isSignedIn, async (signedIn) => {
13+
if (signedIn) {
14+
await getToken.value()
15+
navigateTo("/")
16+
}
17+
}, { immediate: true })
18+
})
19+
</script>

frontend/app/pages/login.vue

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<template>
2+
<div class="flex items-center justify-center h-screen">
3+
<SignedOut>
4+
<SignInButton
5+
class="rounded-lg border border-gray-900 px-10 py-2 hover:bg-gray-900 hover:text-white transition-colors"
6+
/>
7+
</SignedOut>
8+
<SignedIn>
9+
<UserButton />
10+
</SignedIn>
11+
</div>
12+
</template>
13+
14+
<script setup lang="ts">
15+
const { isSignedIn, getToken } = useAuth()
16+
17+
if (import.meta.client && isSignedIn.value) {
18+
await getToken.value()
19+
navigateTo("/")
20+
}
21+
</script>

0 commit comments

Comments
 (0)