Commit 93cc08f 1 parent f2ca1ee commit 93cc08f Copy full SHA for 93cc08f
File tree 7 files changed +13
-53
lines changed
server/api/auth/providers
7 files changed +13
-53
lines changed Original file line number Diff line number Diff line change 1
1
export default defineNuxtRouteMiddleware ( ( ) => {
2
- const { user } = useHub ( ) . auth
2
+ const { loggedIn } = useUserSession ( )
3
3
4
- if ( ! user . value ) {
4
+ if ( ! loggedIn . value ) {
5
5
return navigateTo ( '/' )
6
6
}
7
7
} )
Original file line number Diff line number Diff line change 1
1
<script setup lang="ts">
2
- const { auth } = useHub ()
3
2
const { user } = useUserSession ()
4
3
</script >
5
4
@@ -10,8 +9,7 @@ const { user } = useUserSession()
10
9
Todo List
11
10
</h3 >
12
11
<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"
15
13
/>
16
14
<div v-else class =" space-x-2" >
17
15
<UButton to =" /todos" icon =" i-heroicons-list-bullet" label =" Go to Todos" color =" black" />
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ const newTodo = ref('')
7
7
const newTodoInput = ref (null )
8
8
9
9
const toast = useToast ()
10
- const { user , logout } = useHub (). auth
10
+ const { user , clear } = useUserSession ()
11
11
const { data: todos } = await useFetch (' /api/todos' )
12
12
13
13
async function addTodo () {
@@ -55,7 +55,7 @@ async function deleteTodo (todo) {
55
55
const items = [[{
56
56
label: ' Logout' ,
57
57
icon: ' i-heroicons-arrow-left-on-rectangle' ,
58
- click: logout
58
+ click: clear
59
59
}]]
60
60
< / script>
61
61
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ export default oauth . githubEventHandler ( {
2
+ async onSuccess ( event , { user } ) {
3
+ await setUserSession ( event , {
4
+ user
5
+ } )
6
+ return sendRedirect ( event , '/' )
7
+ }
8
+ } )
Load Diff This file was deleted.
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments