Skip to content

Commit 9634922

Browse files
committed
refactor: signout logic
1 parent ea1db43 commit 9634922

File tree

3 files changed

+21
-7
lines changed

3 files changed

+21
-7
lines changed

src/module.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,13 @@ export default defineNuxtModule<ModuleOptions>({
173173
file: resolver.resolve('./runtime/pages/SignUp.vue'),
174174
})
175175

176+
// Sign Out
177+
pages.unshift({
178+
name: 'signout',
179+
path: '/signout',
180+
file: resolver.resolve('./runtime/pages/SignOut.vue'),
181+
})
182+
176183
// Account
177184
pages.unshift({
178185
name: 'account',

src/runtime/composables/firebase.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,11 @@ import { navigateTo } from '#imports'
44

55
export const useSignOut = () => {
66
// App state
7-
const auth = useFirebaseAuth()!
7+
const auth = useFirebaseAuth()
88

99
const signOut = async (redirectTo = '/signin') => {
10-
if (!auth) {
11-
console.error('Firebase auth not available.')
12-
return
13-
}
14-
1510
// Sign out from Firebase Auth
16-
await firebaseSignOut(auth)
11+
if (auth) await firebaseSignOut(auth)
1712

1813
// Redirect
1914
await navigateTo(redirectTo)

src/runtime/pages/SignOut.vue

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<script setup lang="ts">
2+
import { useSignOut } from '#imports'
3+
4+
// STATE - GLOBAL
5+
const { signOut } = useSignOut()
6+
7+
await signOut()
8+
</script>
9+
10+
<template>
11+
<p>Signing out...</p>
12+
</template>

0 commit comments

Comments
 (0)