Skip to content

Commit 93cc08f

Browse files
committed
fix!: remove useHub() composable
1 parent f2ca1ee commit 93cc08f

File tree

7 files changed

+13
-53
lines changed

7 files changed

+13
-53
lines changed

_demo/middleware/auth.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export default defineNuxtRouteMiddleware(() => {
2-
const { user } = useHub().auth
2+
const { loggedIn } = useUserSession()
33

4-
if (!user.value) {
4+
if (!loggedIn.value) {
55
return navigateTo('/')
66
}
77
})

_demo/pages/index.vue

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<script setup lang="ts">
2-
const { auth } = useHub()
32
const { user } = useUserSession()
43
</script>
54

@@ -10,8 +9,7 @@ const { user } = useUserSession()
109
Todo List
1110
</h3>
1211
<UButton
13-
v-if="!user" icon="i-simple-icons-github" label="Login with GitHub" color="black" external
14-
@click="auth.loginWith('github', { redirectSuccess: '/todos' })"
12+
v-if="!user" icon="i-simple-icons-github" label="Login with GitHub" color="black" external to="/auth/github"
1513
/>
1614
<div v-else class="space-x-2">
1715
<UButton to="/todos" icon="i-heroicons-list-bullet" label="Go to Todos" color="black" />

_demo/pages/todos.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const newTodo = ref('')
77
const newTodoInput = ref(null)
88
99
const toast = useToast()
10-
const { user, logout } = useHub().auth
10+
const { user, clear } = useUserSession()
1111
const { data: todos } = await useFetch('/api/todos')
1212
1313
async function addTodo () {
@@ -55,7 +55,7 @@ async function deleteTodo (todo) {
5555
const items = [[{
5656
label: 'Logout',
5757
icon: 'i-heroicons-arrow-left-on-rectangle',
58-
click: logout
58+
click: clear
5959
}]]
6060
</script>
6161

_demo/server/plugins/auth.ts

-5
This file was deleted.
+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export default oauth.githubEventHandler({
2+
async onSuccess(event, { user }) {
3+
await setUserSession(event, {
4+
user
5+
})
6+
return sendRedirect(event, '/')
7+
}
8+
})

composables/hub.ts

-17
This file was deleted.

server/api/auth/providers/[...provider].get.ts

-24
This file was deleted.

0 commit comments

Comments
 (0)