mirror of
https://github.com/ArthurDanjou/arthome.git
synced 2026-01-14 12:14:33 +01:00
Add auth
This commit is contained in:
@@ -1 +1,4 @@
|
||||
NUXT_SESSION_PASSWORD=
|
||||
NUXT_SESSION_PASSWORD=
|
||||
NUXT_OAUTH_GITHUB_CLIENT_ID=
|
||||
NUXT_OAUTH_GITHUB_CLIENT_SECRET=
|
||||
NUXT_HUB_PROJECT_KEY=
|
||||
@@ -2,8 +2,5 @@ export default defineAppConfig({
|
||||
ui: {
|
||||
gray: 'neutral',
|
||||
primary: 'gray',
|
||||
icons: {
|
||||
dynamic: true,
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
75
app/app.vue
75
app/app.vue
@@ -1,38 +1,54 @@
|
||||
<script lang="ts" setup>
|
||||
useHead({
|
||||
link: [{ rel: 'icon', type: 'image/png', href: '/favicon.ico' }],
|
||||
title: 'Home by Arthur Danjou',
|
||||
})
|
||||
|
||||
const date = ref<Date>(new Date())
|
||||
onMounted(() => {
|
||||
setInterval(() => date.value = new Date(), 1000)
|
||||
const { loggedIn, clear, user } = useUserSession()
|
||||
const colorMode = useColorMode()
|
||||
const authorized = await isAuthorized()
|
||||
|
||||
onMounted(async () => {
|
||||
if (!authorized) {
|
||||
navigateTo('/')
|
||||
}
|
||||
})
|
||||
|
||||
const apps = await queryContent('/').find()
|
||||
const nuxt = apps.filter(app => app._dir === 'nuxt')
|
||||
const perso = apps.filter(app => app._dir === 'perso')
|
||||
const maths = apps.filter(app => app._dir === 'maths')
|
||||
const social = apps.filter(app => app._dir === 'social')
|
||||
watch(loggedIn, async () => {
|
||||
if (!loggedIn.value) {
|
||||
navigateTo('/')
|
||||
}
|
||||
})
|
||||
|
||||
function toggleColorMode() {
|
||||
colorMode.preference = colorMode.preference === 'dark' ? 'light' : 'dark'
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<NuxtLoadingIndicator color="#808080" />
|
||||
<UContainer class="my-8">
|
||||
<div v-if="date" class="flex flex-col items-center">
|
||||
<h1 class="text-6xl font-bold">
|
||||
{{ useDateFormat(date, 'HH:mm') }}
|
||||
</h1>
|
||||
<h1 class="text-2xl">
|
||||
{{ useDateFormat(date, 'dddd D MMMM YYYY', { locales: () => 'fr-FR' }) }}
|
||||
</h1>
|
||||
</div>
|
||||
<div v-if="apps" class="space-y-12">
|
||||
<Application title="Personal" :apps="perso" />
|
||||
<Application title="Social" :apps="social" />
|
||||
<Application title="Nuxt" :apps="nuxt" />
|
||||
<Application title="Mathematics" :apps="maths" />
|
||||
<UContainer>
|
||||
<div class="absolute top-2 right-2 flex gap-2">
|
||||
<UTooltip v-if="loggedIn" text="Click to logout">
|
||||
<UButton
|
||||
:label="`Hello ${user.name}`"
|
||||
color="gray"
|
||||
square
|
||||
trailing-icon="i-ph:person-arms-spread-duotone"
|
||||
variant="ghost"
|
||||
@click="clear"
|
||||
/>
|
||||
</UTooltip>
|
||||
<UButton
|
||||
:icon="$colorMode.preference === 'dark' ? 'i-ph:moon-duotone' : 'i-ph:sun-duotone'"
|
||||
color="gray"
|
||||
square
|
||||
variant="ghost"
|
||||
@click="toggleColorMode"
|
||||
/>
|
||||
</div>
|
||||
<NuxtPage />
|
||||
</UContainer>
|
||||
</div>
|
||||
</template>
|
||||
@@ -42,19 +58,4 @@ body {
|
||||
font-family: 'DM Sans', sans-serif;
|
||||
@apply h-full w-full text-neutral-700 dark:text-neutral-300;
|
||||
}
|
||||
|
||||
.page-enter-active,
|
||||
.page-leave-active {
|
||||
transition: all 0.2s;
|
||||
}
|
||||
|
||||
.page-leave-to {
|
||||
opacity: 0;
|
||||
transform: translateY(-5px);
|
||||
}
|
||||
|
||||
.page-enter-from {
|
||||
opacity: 0;
|
||||
transform: translateY(5px);
|
||||
}
|
||||
</style>
|
||||
|
||||
10
app/composables/authorization.ts
Normal file
10
app/composables/authorization.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
export async function isAuthorized() {
|
||||
const { user } = useUserSession()
|
||||
const { data: authorized } = await useFetch('/api/authorized', {
|
||||
method: 'POST',
|
||||
body: {
|
||||
email: user.value?.email ?? 'test@nuxt.com',
|
||||
},
|
||||
})
|
||||
return authorized.value
|
||||
}
|
||||
8
app/middleware/auth.ts
Normal file
8
app/middleware/auth.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
export default defineNuxtRouteMiddleware(async () => {
|
||||
const { loggedIn } = useUserSession()
|
||||
const authorized = await isAuthorized()
|
||||
|
||||
if (!loggedIn.value || !authorized) {
|
||||
return navigateTo('/')
|
||||
}
|
||||
})
|
||||
35
app/pages/home.vue
Normal file
35
app/pages/home.vue
Normal file
@@ -0,0 +1,35 @@
|
||||
<script lang="ts" setup>
|
||||
definePageMeta({
|
||||
middleware: 'auth',
|
||||
})
|
||||
|
||||
const date = ref<Date>(new Date())
|
||||
onMounted(() => {
|
||||
setInterval(() => date.value = new Date(), 1000)
|
||||
})
|
||||
|
||||
const apps = await queryContent('/').find()
|
||||
const nuxt = apps.filter(app => app._dir === 'nuxt')
|
||||
const perso = apps.filter(app => app._dir === 'perso')
|
||||
const maths = apps.filter(app => app._dir === 'maths')
|
||||
const social = apps.filter(app => app._dir === 'social')
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<main class="my-8">
|
||||
<div v-if="date" class="flex flex-col items-center">
|
||||
<h1 class="text-6xl font-bold">
|
||||
{{ useDateFormat(date, 'HH:mm') }}
|
||||
</h1>
|
||||
<h1 class="text-2xl">
|
||||
{{ useDateFormat(date, 'dddd D MMMM YYYY', { locales: () => 'fr-FR' }) }}
|
||||
</h1>
|
||||
</div>
|
||||
<div v-if="apps" class="space-y-12">
|
||||
<Application :apps="perso" title="Personal" />
|
||||
<Application :apps="social" title="Social" />
|
||||
<Application :apps="nuxt" title="Nuxt" />
|
||||
<Application :apps="maths" title="Mathematics" />
|
||||
</div>
|
||||
</main>
|
||||
</template>
|
||||
59
app/pages/index.vue
Normal file
59
app/pages/index.vue
Normal file
@@ -0,0 +1,59 @@
|
||||
<script lang="ts" setup>
|
||||
const { loggedIn } = useUserSession()
|
||||
const authorized = await isAuthorized()
|
||||
|
||||
onMounted(() => {
|
||||
if (authorized) {
|
||||
navigateTo('/home')
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="min-h-screen flex items-center justify-center">
|
||||
<UCard class="w-full md:w-1/2">
|
||||
<template #header>
|
||||
<div class="flex justify-between items-center">
|
||||
<h3>Home by Arthur Danjou</h3>
|
||||
<UButton
|
||||
v-if="!loggedIn"
|
||||
:external="true"
|
||||
color="black"
|
||||
icon="i-ph:github-logo-duotone"
|
||||
label="Login with GitHub"
|
||||
to="/auth/github"
|
||||
/>
|
||||
<UButton
|
||||
v-if="authorized"
|
||||
color="black"
|
||||
icon="i-ph:house-duotone"
|
||||
label="Go Home"
|
||||
to="/home"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
<template #default>
|
||||
<h1 class="font-bold text-black dark:text-white text-lg">
|
||||
Welcome to ArtHome
|
||||
</h1>
|
||||
<p v-if="!authorized && loggedIn">
|
||||
You're not authorized to access
|
||||
</p>
|
||||
<p>
|
||||
ArtHome is a private platform. You need to request access to be able to use it by asking to
|
||||
<a
|
||||
class="duration-300 underline-offset-2 text-md text-black dark:text-white underline decoration-gray-300 dark:decoration-neutral-700 hover:decoration-black dark:hover:decoration-white"
|
||||
href="mailto:arthurdanjou@outlook.fr"
|
||||
rel="noopener"
|
||||
target="_blank"
|
||||
>Arthur Danjou</a>
|
||||
</p>
|
||||
</template>
|
||||
<template #footer>
|
||||
<p class="italic text-sm">
|
||||
No personal informations regarding your GitHub account are stored in database.
|
||||
</p>
|
||||
</template>
|
||||
</UCard>
|
||||
</div>
|
||||
</template>
|
||||
@@ -9,4 +9,4 @@
|
||||
],
|
||||
"icon": "i-icon-park-outline:geometric-flowers",
|
||||
"color": "indigo"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,4 +9,4 @@
|
||||
],
|
||||
"icon": "i-ph:math-operations-duotone",
|
||||
"color": "stone"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,4 +9,4 @@
|
||||
],
|
||||
"icon": "i-vscode-icons:file-type-wolfram",
|
||||
"color": "red"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,11 +6,12 @@
|
||||
{
|
||||
"name": "Nuxt",
|
||||
"color": "emerald"
|
||||
}, {
|
||||
},
|
||||
{
|
||||
"name": "Doc",
|
||||
"color": "purple"
|
||||
}
|
||||
],
|
||||
"icon": "i-logos:nuxt-icon",
|
||||
"color": "green"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,11 +6,12 @@
|
||||
{
|
||||
"name": "Nuxt",
|
||||
"color": "emerald"
|
||||
}, {
|
||||
},
|
||||
{
|
||||
"name": "Doc",
|
||||
"color": "purple"
|
||||
}
|
||||
],
|
||||
"icon": "i-logos:nuxt-icon",
|
||||
"color": "green"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,11 +6,12 @@
|
||||
{
|
||||
"name": "Nuxt",
|
||||
"color": "emerald"
|
||||
}, {
|
||||
},
|
||||
{
|
||||
"name": "Doc",
|
||||
"color": "purple"
|
||||
}
|
||||
],
|
||||
"icon": "i-logos:nuxt-icon",
|
||||
"color": "zinc"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,11 +6,12 @@
|
||||
{
|
||||
"name": "Nuxt",
|
||||
"color": "emerald"
|
||||
}, {
|
||||
},
|
||||
{
|
||||
"name": "Doc",
|
||||
"color": "purple"
|
||||
}
|
||||
],
|
||||
"icon": "i-logos:nuxt-icon",
|
||||
"color": "green"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,11 +6,12 @@
|
||||
{
|
||||
"name": "Nuxt",
|
||||
"color": "emerald"
|
||||
}, {
|
||||
},
|
||||
{
|
||||
"name": "Doc",
|
||||
"color": "purple"
|
||||
}
|
||||
],
|
||||
"icon": "i-logos:nuxt-icon",
|
||||
"color": "green"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,11 +5,12 @@
|
||||
{
|
||||
"name": "Nuxt",
|
||||
"color": "emerald"
|
||||
}, {
|
||||
},
|
||||
{
|
||||
"name": "Doc",
|
||||
"color": "purple"
|
||||
}
|
||||
],
|
||||
"icon": "i-logos:nuxt-icon",
|
||||
"color": "green"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,4 +14,4 @@
|
||||
],
|
||||
"icon": "i-logos:vueuse",
|
||||
"color": "green"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,4 +13,4 @@
|
||||
],
|
||||
"icon": "i-ph:globe-duotone",
|
||||
"color": "blue"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,4 +9,4 @@
|
||||
],
|
||||
"icon": "i-ph:bird-duotone",
|
||||
"color": "lime"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,4 +13,4 @@
|
||||
],
|
||||
"icon": "i-ph:github-logo-duotone",
|
||||
"color": "black"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,4 +13,4 @@
|
||||
],
|
||||
"icon": "i-ph:instagram-logo-duotone",
|
||||
"color": "fuchsia"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,4 +13,4 @@
|
||||
],
|
||||
"icon": "i-ph:linkedin-logo-duotone",
|
||||
"color": "blue"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,4 +13,4 @@
|
||||
],
|
||||
"icon": "i-ph:twitch-logo-duotone",
|
||||
"color": "purple"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,4 +13,4 @@
|
||||
],
|
||||
"icon": "i-ph:x-logo-duotone",
|
||||
"color": "black"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,4 +13,4 @@
|
||||
],
|
||||
"icon": "i-ph:youtube-logo-duotone",
|
||||
"color": "red"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ export default defineNuxtConfig({
|
||||
hub: {
|
||||
cache: true,
|
||||
analytics: true,
|
||||
database: true,
|
||||
},
|
||||
|
||||
// Nuxt Icon
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
"@nuxthq/studio": "^2.0.3",
|
||||
"@nuxthub/core": "^0.7.3",
|
||||
"@nuxtjs/google-fonts": "^3.2.0",
|
||||
"drizzle-orm": "^0.33.0",
|
||||
"drizzle-orm": "^0.32.1",
|
||||
"h3-zod": "^0.5.3",
|
||||
"nuxt": "^3.12.4",
|
||||
"nuxt-auth-utils": "^0.3.4",
|
||||
@@ -32,7 +32,7 @@
|
||||
"@types/node": "^22.4.2",
|
||||
"@vueuse/core": "^11.0.1",
|
||||
"@vueuse/nuxt": "^11.0.1",
|
||||
"drizzle-kit": "^0.24.0",
|
||||
"drizzle-kit": "^0.23.0",
|
||||
"eslint": "^9.9.0",
|
||||
"typescript": "^5.5.4",
|
||||
"vue-tsc": "^2.0.29",
|
||||
|
||||
82
pnpm-lock.yaml
generated
82
pnpm-lock.yaml
generated
@@ -10,7 +10,7 @@ importers:
|
||||
dependencies:
|
||||
'@nuxt/content':
|
||||
specifier: ^2.13.2
|
||||
version: 2.13.2(ioredis@5.4.1)(magicast@0.3.4)(nuxt@3.12.4(@parcel/watcher@2.4.1)(@types/node@22.4.2)(drizzle-orm@0.33.0(@cloudflare/workers-types@4.20240815.0))(eslint@9.9.0(jiti@1.21.6))(ioredis@5.4.1)(magicast@0.3.4)(optionator@0.9.4)(rollup@4.19.0)(terser@5.31.3)(typescript@5.5.4)(vite@5.3.4(@types/node@22.4.2)(terser@5.31.3))(vue-tsc@2.0.29(typescript@5.5.4)))(rollup@4.19.0)(vue@3.4.38(typescript@5.5.4))
|
||||
version: 2.13.2(ioredis@5.4.1)(magicast@0.3.4)(nuxt@3.12.4(@parcel/watcher@2.4.1)(@types/node@22.4.2)(drizzle-orm@0.32.2(@cloudflare/workers-types@4.20240815.0))(eslint@9.9.0(jiti@1.21.6))(ioredis@5.4.1)(magicast@0.3.4)(optionator@0.9.4)(rollup@4.19.0)(terser@5.31.3)(typescript@5.5.4)(vite@5.3.4(@types/node@22.4.2)(terser@5.31.3))(vue-tsc@2.0.29(typescript@5.5.4)))(rollup@4.19.0)(vue@3.4.38(typescript@5.5.4))
|
||||
'@nuxthq/studio':
|
||||
specifier: ^2.0.3
|
||||
version: 2.0.3(magicast@0.3.4)(rollup@4.19.0)
|
||||
@@ -21,14 +21,14 @@ importers:
|
||||
specifier: ^3.2.0
|
||||
version: 3.2.0(magicast@0.3.4)(rollup@4.19.0)
|
||||
drizzle-orm:
|
||||
specifier: ^0.33.0
|
||||
version: 0.33.0(@cloudflare/workers-types@4.20240815.0)
|
||||
specifier: ^0.32.1
|
||||
version: 0.32.2(@cloudflare/workers-types@4.20240815.0)
|
||||
h3-zod:
|
||||
specifier: ^0.5.3
|
||||
version: 0.5.3(h3@1.12.0)(zod@3.23.8)
|
||||
nuxt:
|
||||
specifier: ^3.12.4
|
||||
version: 3.12.4(@parcel/watcher@2.4.1)(@types/node@22.4.2)(drizzle-orm@0.33.0(@cloudflare/workers-types@4.20240815.0))(eslint@9.9.0(jiti@1.21.6))(ioredis@5.4.1)(magicast@0.3.4)(optionator@0.9.4)(rollup@4.19.0)(terser@5.31.3)(typescript@5.5.4)(vite@5.3.4(@types/node@22.4.2)(terser@5.31.3))(vue-tsc@2.0.29(typescript@5.5.4))
|
||||
version: 3.12.4(@parcel/watcher@2.4.1)(@types/node@22.4.2)(drizzle-orm@0.32.2(@cloudflare/workers-types@4.20240815.0))(eslint@9.9.0(jiti@1.21.6))(ioredis@5.4.1)(magicast@0.3.4)(optionator@0.9.4)(rollup@4.19.0)(terser@5.31.3)(typescript@5.5.4)(vite@5.3.4(@types/node@22.4.2)(terser@5.31.3))(vue-tsc@2.0.29(typescript@5.5.4))
|
||||
nuxt-auth-utils:
|
||||
specifier: ^0.3.4
|
||||
version: 0.3.4(magicast@0.3.4)(rollup@4.19.0)
|
||||
@@ -56,10 +56,10 @@ importers:
|
||||
version: 11.0.1(vue@3.4.38(typescript@5.5.4))
|
||||
'@vueuse/nuxt':
|
||||
specifier: ^11.0.1
|
||||
version: 11.0.1(magicast@0.3.4)(nuxt@3.12.4(@parcel/watcher@2.4.1)(@types/node@22.4.2)(drizzle-orm@0.33.0(@cloudflare/workers-types@4.20240815.0))(eslint@9.9.0(jiti@1.21.6))(ioredis@5.4.1)(magicast@0.3.4)(optionator@0.9.4)(rollup@4.19.0)(terser@5.31.3)(typescript@5.5.4)(vite@5.3.4(@types/node@22.4.2)(terser@5.31.3))(vue-tsc@2.0.29(typescript@5.5.4)))(rollup@4.19.0)(vue@3.4.38(typescript@5.5.4))
|
||||
version: 11.0.1(magicast@0.3.4)(nuxt@3.12.4(@parcel/watcher@2.4.1)(@types/node@22.4.2)(drizzle-orm@0.32.2(@cloudflare/workers-types@4.20240815.0))(eslint@9.9.0(jiti@1.21.6))(ioredis@5.4.1)(magicast@0.3.4)(optionator@0.9.4)(rollup@4.19.0)(terser@5.31.3)(typescript@5.5.4)(vite@5.3.4(@types/node@22.4.2)(terser@5.31.3))(vue-tsc@2.0.29(typescript@5.5.4)))(rollup@4.19.0)(vue@3.4.38(typescript@5.5.4))
|
||||
drizzle-kit:
|
||||
specifier: ^0.24.0
|
||||
version: 0.24.0
|
||||
specifier: ^0.23.0
|
||||
version: 0.23.2
|
||||
eslint:
|
||||
specifier: ^9.9.0
|
||||
version: 9.9.0(jiti@1.21.6)
|
||||
@@ -2832,12 +2832,12 @@ packages:
|
||||
resolution: {integrity: sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg==}
|
||||
engines: {node: '>=12'}
|
||||
|
||||
drizzle-kit@0.24.0:
|
||||
resolution: {integrity: sha512-rUl5Rf5HLOVkAwHEVEi8xgulIRWzoys0q77RHGCxv5e9v8AI3JGFg7Ug5K1kn513RwNZbuNJMUKOXo0j8kPRgg==}
|
||||
drizzle-kit@0.23.2:
|
||||
resolution: {integrity: sha512-NWkQ7GD2OTbQ7HzcjsaCOf3n0tlFPSEAF38fvDpwDj8jRbGWGFtN2cD8I8wp4lU+5Os/oyP2xycTKGLHdPipUw==}
|
||||
hasBin: true
|
||||
|
||||
drizzle-orm@0.33.0:
|
||||
resolution: {integrity: sha512-SHy72R2Rdkz0LEq0PSG/IdvnT3nGiWuRk+2tXZQ90GVq/XQhpCzu/EFT3V2rox+w8MlkBQxifF8pCStNYnERfA==}
|
||||
drizzle-orm@0.32.2:
|
||||
resolution: {integrity: sha512-3fXKzPzrgZIcnWCSLiERKN5Opf9Iagrag75snfFlKeKSYB1nlgPBshzW3Zn6dQymkyiib+xc4nIz0t8U+Xdpuw==}
|
||||
peerDependencies:
|
||||
'@aws-sdk/client-rds-data': '>=3'
|
||||
'@cloudflare/workers-types': '>=3'
|
||||
@@ -2980,8 +2980,8 @@ packages:
|
||||
es-module-lexer@1.5.4:
|
||||
resolution: {integrity: sha512-MVNK56NiMrOwitFB7cqDwq0CQutbw+0BvLshJSse0MUNU+y1FC3bUS/AQg7oUng+/wKrrki7JfmwtVHkVfPLlw==}
|
||||
|
||||
esbuild-register@3.5.0:
|
||||
resolution: {integrity: sha512-+4G/XmakeBAsvJuDugJvtyF1x+XJT4FMocynNpxrvEBViirpfUn2PgNpCHedfWhF4WokNsO/OvMKrmJOIJsI5A==}
|
||||
esbuild-register@3.6.0:
|
||||
resolution: {integrity: sha512-H2/S7Pm8a9CL1uhp9OvjwrBh5Pvx0H8qVOxNu8Wed9Y7qv56MPtq+GGM8RJpq6glYJn9Wspr8uw7l55uyinNeg==}
|
||||
peerDependencies:
|
||||
esbuild: '>=0.12 <1'
|
||||
|
||||
@@ -6185,7 +6185,7 @@ snapshots:
|
||||
'@babel/helper-split-export-declaration': 7.24.7
|
||||
'@babel/parser': 7.24.8
|
||||
'@babel/types': 7.24.9
|
||||
debug: 4.3.5
|
||||
debug: 4.3.6
|
||||
globals: 11.12.0
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
@@ -6811,7 +6811,7 @@ snapshots:
|
||||
|
||||
'@koa/router@12.0.1':
|
||||
dependencies:
|
||||
debug: 4.3.5
|
||||
debug: 4.3.6
|
||||
http-errors: 2.0.0
|
||||
koa-compose: 4.1.0
|
||||
methods: 1.1.2
|
||||
@@ -6865,13 +6865,13 @@ snapshots:
|
||||
'@nodelib/fs.scandir': 2.1.5
|
||||
fastq: 1.17.1
|
||||
|
||||
'@nuxt/content@2.13.2(ioredis@5.4.1)(magicast@0.3.4)(nuxt@3.12.4(@parcel/watcher@2.4.1)(@types/node@22.4.2)(drizzle-orm@0.33.0(@cloudflare/workers-types@4.20240815.0))(eslint@9.9.0(jiti@1.21.6))(ioredis@5.4.1)(magicast@0.3.4)(optionator@0.9.4)(rollup@4.19.0)(terser@5.31.3)(typescript@5.5.4)(vite@5.3.4(@types/node@22.4.2)(terser@5.31.3))(vue-tsc@2.0.29(typescript@5.5.4)))(rollup@4.19.0)(vue@3.4.38(typescript@5.5.4))':
|
||||
'@nuxt/content@2.13.2(ioredis@5.4.1)(magicast@0.3.4)(nuxt@3.12.4(@parcel/watcher@2.4.1)(@types/node@22.4.2)(drizzle-orm@0.32.2(@cloudflare/workers-types@4.20240815.0))(eslint@9.9.0(jiti@1.21.6))(ioredis@5.4.1)(magicast@0.3.4)(optionator@0.9.4)(rollup@4.19.0)(terser@5.31.3)(typescript@5.5.4)(vite@5.3.4(@types/node@22.4.2)(terser@5.31.3))(vue-tsc@2.0.29(typescript@5.5.4)))(rollup@4.19.0)(vue@3.4.38(typescript@5.5.4))':
|
||||
dependencies:
|
||||
'@nuxt/kit': 3.12.4(magicast@0.3.4)(rollup@4.19.0)
|
||||
'@nuxtjs/mdc': 0.8.3(magicast@0.3.4)(rollup@4.19.0)
|
||||
'@vueuse/core': 10.11.0(vue@3.4.38(typescript@5.5.4))
|
||||
'@vueuse/head': 2.0.0(vue@3.4.38(typescript@5.5.4))
|
||||
'@vueuse/nuxt': 10.11.1(magicast@0.3.4)(nuxt@3.12.4(@parcel/watcher@2.4.1)(@types/node@22.4.2)(drizzle-orm@0.33.0(@cloudflare/workers-types@4.20240815.0))(eslint@9.9.0(jiti@1.21.6))(ioredis@5.4.1)(magicast@0.3.4)(optionator@0.9.4)(rollup@4.19.0)(terser@5.31.3)(typescript@5.5.4)(vite@5.3.4(@types/node@22.4.2)(terser@5.31.3))(vue-tsc@2.0.29(typescript@5.5.4)))(rollup@4.19.0)(vue@3.4.38(typescript@5.5.4))
|
||||
'@vueuse/nuxt': 10.11.1(magicast@0.3.4)(nuxt@3.12.4(@parcel/watcher@2.4.1)(@types/node@22.4.2)(drizzle-orm@0.32.2(@cloudflare/workers-types@4.20240815.0))(eslint@9.9.0(jiti@1.21.6))(ioredis@5.4.1)(magicast@0.3.4)(optionator@0.9.4)(rollup@4.19.0)(terser@5.31.3)(typescript@5.5.4)(vite@5.3.4(@types/node@22.4.2)(terser@5.31.3))(vue-tsc@2.0.29(typescript@5.5.4)))(rollup@4.19.0)(vue@3.4.38(typescript@5.5.4))
|
||||
consola: 3.2.3
|
||||
defu: 6.1.4
|
||||
destr: 2.0.3
|
||||
@@ -7728,7 +7728,7 @@ snapshots:
|
||||
dependencies:
|
||||
'@typescript-eslint/types': 7.17.0
|
||||
'@typescript-eslint/visitor-keys': 7.17.0
|
||||
debug: 4.3.5
|
||||
debug: 4.3.6
|
||||
globby: 11.1.0
|
||||
is-glob: 4.0.3
|
||||
minimatch: 9.0.5
|
||||
@@ -8132,13 +8132,13 @@ snapshots:
|
||||
|
||||
'@vueuse/metadata@11.0.1': {}
|
||||
|
||||
'@vueuse/nuxt@10.11.1(magicast@0.3.4)(nuxt@3.12.4(@parcel/watcher@2.4.1)(@types/node@22.4.2)(drizzle-orm@0.33.0(@cloudflare/workers-types@4.20240815.0))(eslint@9.9.0(jiti@1.21.6))(ioredis@5.4.1)(magicast@0.3.4)(optionator@0.9.4)(rollup@4.19.0)(terser@5.31.3)(typescript@5.5.4)(vite@5.3.4(@types/node@22.4.2)(terser@5.31.3))(vue-tsc@2.0.29(typescript@5.5.4)))(rollup@4.19.0)(vue@3.4.38(typescript@5.5.4))':
|
||||
'@vueuse/nuxt@10.11.1(magicast@0.3.4)(nuxt@3.12.4(@parcel/watcher@2.4.1)(@types/node@22.4.2)(drizzle-orm@0.32.2(@cloudflare/workers-types@4.20240815.0))(eslint@9.9.0(jiti@1.21.6))(ioredis@5.4.1)(magicast@0.3.4)(optionator@0.9.4)(rollup@4.19.0)(terser@5.31.3)(typescript@5.5.4)(vite@5.3.4(@types/node@22.4.2)(terser@5.31.3))(vue-tsc@2.0.29(typescript@5.5.4)))(rollup@4.19.0)(vue@3.4.38(typescript@5.5.4))':
|
||||
dependencies:
|
||||
'@nuxt/kit': 3.12.4(magicast@0.3.4)(rollup@4.19.0)
|
||||
'@vueuse/core': 10.11.1(vue@3.4.38(typescript@5.5.4))
|
||||
'@vueuse/metadata': 10.11.1
|
||||
local-pkg: 0.5.0
|
||||
nuxt: 3.12.4(@parcel/watcher@2.4.1)(@types/node@22.4.2)(drizzle-orm@0.33.0(@cloudflare/workers-types@4.20240815.0))(eslint@9.9.0(jiti@1.21.6))(ioredis@5.4.1)(magicast@0.3.4)(optionator@0.9.4)(rollup@4.19.0)(terser@5.31.3)(typescript@5.5.4)(vite@5.3.4(@types/node@22.4.2)(terser@5.31.3))(vue-tsc@2.0.29(typescript@5.5.4))
|
||||
nuxt: 3.12.4(@parcel/watcher@2.4.1)(@types/node@22.4.2)(drizzle-orm@0.32.2(@cloudflare/workers-types@4.20240815.0))(eslint@9.9.0(jiti@1.21.6))(ioredis@5.4.1)(magicast@0.3.4)(optionator@0.9.4)(rollup@4.19.0)(terser@5.31.3)(typescript@5.5.4)(vite@5.3.4(@types/node@22.4.2)(terser@5.31.3))(vue-tsc@2.0.29(typescript@5.5.4))
|
||||
vue-demi: 0.14.10(vue@3.4.38(typescript@5.5.4))
|
||||
transitivePeerDependencies:
|
||||
- '@vue/composition-api'
|
||||
@@ -8147,13 +8147,13 @@ snapshots:
|
||||
- supports-color
|
||||
- vue
|
||||
|
||||
'@vueuse/nuxt@11.0.1(magicast@0.3.4)(nuxt@3.12.4(@parcel/watcher@2.4.1)(@types/node@22.4.2)(drizzle-orm@0.33.0(@cloudflare/workers-types@4.20240815.0))(eslint@9.9.0(jiti@1.21.6))(ioredis@5.4.1)(magicast@0.3.4)(optionator@0.9.4)(rollup@4.19.0)(terser@5.31.3)(typescript@5.5.4)(vite@5.3.4(@types/node@22.4.2)(terser@5.31.3))(vue-tsc@2.0.29(typescript@5.5.4)))(rollup@4.19.0)(vue@3.4.38(typescript@5.5.4))':
|
||||
'@vueuse/nuxt@11.0.1(magicast@0.3.4)(nuxt@3.12.4(@parcel/watcher@2.4.1)(@types/node@22.4.2)(drizzle-orm@0.32.2(@cloudflare/workers-types@4.20240815.0))(eslint@9.9.0(jiti@1.21.6))(ioredis@5.4.1)(magicast@0.3.4)(optionator@0.9.4)(rollup@4.19.0)(terser@5.31.3)(typescript@5.5.4)(vite@5.3.4(@types/node@22.4.2)(terser@5.31.3))(vue-tsc@2.0.29(typescript@5.5.4)))(rollup@4.19.0)(vue@3.4.38(typescript@5.5.4))':
|
||||
dependencies:
|
||||
'@nuxt/kit': 3.12.4(magicast@0.3.4)(rollup@4.19.0)
|
||||
'@vueuse/core': 11.0.1(vue@3.4.38(typescript@5.5.4))
|
||||
'@vueuse/metadata': 11.0.1
|
||||
local-pkg: 0.5.0
|
||||
nuxt: 3.12.4(@parcel/watcher@2.4.1)(@types/node@22.4.2)(drizzle-orm@0.33.0(@cloudflare/workers-types@4.20240815.0))(eslint@9.9.0(jiti@1.21.6))(ioredis@5.4.1)(magicast@0.3.4)(optionator@0.9.4)(rollup@4.19.0)(terser@5.31.3)(typescript@5.5.4)(vite@5.3.4(@types/node@22.4.2)(terser@5.31.3))(vue-tsc@2.0.29(typescript@5.5.4))
|
||||
nuxt: 3.12.4(@parcel/watcher@2.4.1)(@types/node@22.4.2)(drizzle-orm@0.32.2(@cloudflare/workers-types@4.20240815.0))(eslint@9.9.0(jiti@1.21.6))(ioredis@5.4.1)(magicast@0.3.4)(optionator@0.9.4)(rollup@4.19.0)(terser@5.31.3)(typescript@5.5.4)(vite@5.3.4(@types/node@22.4.2)(terser@5.31.3))(vue-tsc@2.0.29(typescript@5.5.4))
|
||||
vue-demi: 0.14.10(vue@3.4.38(typescript@5.5.4))
|
||||
transitivePeerDependencies:
|
||||
- '@vue/composition-api'
|
||||
@@ -8210,7 +8210,7 @@ snapshots:
|
||||
|
||||
agent-base@6.0.2:
|
||||
dependencies:
|
||||
debug: 4.3.5
|
||||
debug: 4.3.6
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
@@ -8421,7 +8421,7 @@ snapshots:
|
||||
|
||||
capnp-ts@0.7.0:
|
||||
dependencies:
|
||||
debug: 4.3.5
|
||||
debug: 4.3.6
|
||||
tslib: 2.6.3
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
@@ -8679,9 +8679,9 @@ snapshots:
|
||||
|
||||
date-fns@3.6.0: {}
|
||||
|
||||
db0@0.1.4(drizzle-orm@0.33.0(@cloudflare/workers-types@4.20240815.0)):
|
||||
db0@0.1.4(drizzle-orm@0.32.2(@cloudflare/workers-types@4.20240815.0)):
|
||||
optionalDependencies:
|
||||
drizzle-orm: 0.33.0(@cloudflare/workers-types@4.20240815.0)
|
||||
drizzle-orm: 0.32.2(@cloudflare/workers-types@4.20240815.0)
|
||||
|
||||
de-indent@1.0.2: {}
|
||||
|
||||
@@ -8788,16 +8788,16 @@ snapshots:
|
||||
|
||||
dotenv@16.4.5: {}
|
||||
|
||||
drizzle-kit@0.24.0:
|
||||
drizzle-kit@0.23.2:
|
||||
dependencies:
|
||||
'@drizzle-team/brocli': 0.8.2
|
||||
'@esbuild-kit/esm-loader': 2.6.5
|
||||
esbuild: 0.19.12
|
||||
esbuild-register: 3.5.0(esbuild@0.19.12)
|
||||
esbuild-register: 3.6.0(esbuild@0.19.12)
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
drizzle-orm@0.33.0(@cloudflare/workers-types@4.20240815.0):
|
||||
drizzle-orm@0.32.2(@cloudflare/workers-types@4.20240815.0):
|
||||
optionalDependencies:
|
||||
'@cloudflare/workers-types': 4.20240815.0
|
||||
|
||||
@@ -8850,9 +8850,9 @@ snapshots:
|
||||
|
||||
es-module-lexer@1.5.4: {}
|
||||
|
||||
esbuild-register@3.5.0(esbuild@0.19.12):
|
||||
esbuild-register@3.6.0(esbuild@0.19.12):
|
||||
dependencies:
|
||||
debug: 4.3.5
|
||||
debug: 4.3.6
|
||||
esbuild: 0.19.12
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
@@ -9730,7 +9730,7 @@ snapshots:
|
||||
https-proxy-agent@5.0.1:
|
||||
dependencies:
|
||||
agent-base: 6.0.2
|
||||
debug: 4.3.5
|
||||
debug: 4.3.6
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
|
||||
@@ -9774,7 +9774,7 @@ snapshots:
|
||||
dependencies:
|
||||
'@ioredis/commands': 1.2.0
|
||||
cluster-key-slot: 1.1.2
|
||||
debug: 4.3.5
|
||||
debug: 4.3.6
|
||||
denque: 2.1.0
|
||||
lodash.defaults: 4.2.0
|
||||
lodash.isarguments: 3.1.0
|
||||
@@ -9961,7 +9961,7 @@ snapshots:
|
||||
|
||||
koa-send@5.0.1:
|
||||
dependencies:
|
||||
debug: 4.3.5
|
||||
debug: 4.3.6
|
||||
http-errors: 1.8.1
|
||||
resolve-path: 1.4.0
|
||||
transitivePeerDependencies:
|
||||
@@ -9981,7 +9981,7 @@ snapshots:
|
||||
content-disposition: 0.5.4
|
||||
content-type: 1.0.5
|
||||
cookies: 0.9.1
|
||||
debug: 4.3.5
|
||||
debug: 4.3.6
|
||||
delegates: 1.0.0
|
||||
depd: 2.0.0
|
||||
destroy: 1.2.0
|
||||
@@ -10422,7 +10422,7 @@ snapshots:
|
||||
|
||||
micromark@2.11.4:
|
||||
dependencies:
|
||||
debug: 4.3.5
|
||||
debug: 4.3.6
|
||||
parse-entities: 2.0.0
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
@@ -10579,7 +10579,7 @@ snapshots:
|
||||
mlly: 1.7.1
|
||||
pkg-types: 1.1.3
|
||||
|
||||
nitropack@2.9.7(drizzle-orm@0.33.0(@cloudflare/workers-types@4.20240815.0))(magicast@0.3.4):
|
||||
nitropack@2.9.7(drizzle-orm@0.32.2(@cloudflare/workers-types@4.20240815.0))(magicast@0.3.4):
|
||||
dependencies:
|
||||
'@cloudflare/kv-asset-handler': 0.3.4
|
||||
'@netlify/functions': 2.8.1
|
||||
@@ -10602,7 +10602,7 @@ snapshots:
|
||||
cookie-es: 1.2.1
|
||||
croner: 8.1.0
|
||||
crossws: 0.2.4
|
||||
db0: 0.1.4(drizzle-orm@0.33.0(@cloudflare/workers-types@4.20240815.0))
|
||||
db0: 0.1.4(drizzle-orm@0.32.2(@cloudflare/workers-types@4.20240815.0))
|
||||
defu: 6.1.4
|
||||
destr: 2.0.3
|
||||
dot-prop: 8.0.2
|
||||
@@ -10753,7 +10753,7 @@ snapshots:
|
||||
- rollup
|
||||
- supports-color
|
||||
|
||||
nuxt@3.12.4(@parcel/watcher@2.4.1)(@types/node@22.4.2)(drizzle-orm@0.33.0(@cloudflare/workers-types@4.20240815.0))(eslint@9.9.0(jiti@1.21.6))(ioredis@5.4.1)(magicast@0.3.4)(optionator@0.9.4)(rollup@4.19.0)(terser@5.31.3)(typescript@5.5.4)(vite@5.3.4(@types/node@22.4.2)(terser@5.31.3))(vue-tsc@2.0.29(typescript@5.5.4)):
|
||||
nuxt@3.12.4(@parcel/watcher@2.4.1)(@types/node@22.4.2)(drizzle-orm@0.32.2(@cloudflare/workers-types@4.20240815.0))(eslint@9.9.0(jiti@1.21.6))(ioredis@5.4.1)(magicast@0.3.4)(optionator@0.9.4)(rollup@4.19.0)(terser@5.31.3)(typescript@5.5.4)(vite@5.3.4(@types/node@22.4.2)(terser@5.31.3))(vue-tsc@2.0.29(typescript@5.5.4)):
|
||||
dependencies:
|
||||
'@nuxt/devalue': 2.0.2
|
||||
'@nuxt/devtools': 1.3.14(rollup@4.19.0)(vite@5.3.4(@types/node@22.4.2)(terser@5.31.3))
|
||||
@@ -10787,7 +10787,7 @@ snapshots:
|
||||
knitwork: 1.1.0
|
||||
magic-string: 0.30.10
|
||||
mlly: 1.7.1
|
||||
nitropack: 2.9.7(drizzle-orm@0.33.0(@cloudflare/workers-types@4.20240815.0))(magicast@0.3.4)
|
||||
nitropack: 2.9.7(drizzle-orm@0.32.2(@cloudflare/workers-types@4.20240815.0))(magicast@0.3.4)
|
||||
nuxi: 3.12.0
|
||||
nypm: 0.3.9
|
||||
ofetch: 1.3.4
|
||||
@@ -12246,7 +12246,7 @@ snapshots:
|
||||
vite-node@2.0.4(@types/node@22.4.2)(terser@5.31.3):
|
||||
dependencies:
|
||||
cac: 6.7.14
|
||||
debug: 4.3.5
|
||||
debug: 4.3.6
|
||||
pathe: 1.1.2
|
||||
tinyrainbow: 1.2.0
|
||||
vite: 5.3.4(@types/node@22.4.2)(terser@5.31.3)
|
||||
|
||||
10
server/api/authorized.post.ts
Normal file
10
server/api/authorized.post.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { useValidatedBody, z } from 'h3-zod'
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
const users = await useDB().select().from(tables.users).all()
|
||||
const { email } = await useValidatedBody(event, {
|
||||
email: z.string(),
|
||||
})
|
||||
const user = users.find(user => user.email === email)
|
||||
return !!user
|
||||
})
|
||||
@@ -1,3 +0,0 @@
|
||||
export default defineEventHandler(() => {
|
||||
return { hello: 'API' }
|
||||
})
|
||||
@@ -1,5 +0,0 @@
|
||||
CREATE TABLE `users` (
|
||||
`id` integer PRIMARY KEY NOT NULL,
|
||||
`name` text DEFAULT '',
|
||||
`created_at` text DEFAULT (CURRENT_DATE)
|
||||
);
|
||||
@@ -1,49 +0,0 @@
|
||||
{
|
||||
"version": "6",
|
||||
"dialect": "sqlite",
|
||||
"id": "ef8e28cd-73a1-4801-9a0b-7e80169a57c0",
|
||||
"prevId": "00000000-0000-0000-0000-000000000000",
|
||||
"tables": {
|
||||
"users": {
|
||||
"name": "users",
|
||||
"columns": {
|
||||
"id": {
|
||||
"name": "id",
|
||||
"type": "integer",
|
||||
"primaryKey": true,
|
||||
"notNull": true,
|
||||
"autoincrement": false
|
||||
},
|
||||
"name": {
|
||||
"name": "name",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"autoincrement": false,
|
||||
"default": "''"
|
||||
},
|
||||
"created_at": {
|
||||
"name": "created_at",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"autoincrement": false,
|
||||
"default": "(CURRENT_DATE)"
|
||||
}
|
||||
},
|
||||
"indexes": {},
|
||||
"foreignKeys": {},
|
||||
"compositePrimaryKeys": {},
|
||||
"uniqueConstraints": {}
|
||||
}
|
||||
},
|
||||
"enums": {},
|
||||
"_meta": {
|
||||
"schemas": {},
|
||||
"tables": {},
|
||||
"columns": {}
|
||||
},
|
||||
"internal": {
|
||||
"indexes": {}
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
{
|
||||
"version": "7",
|
||||
"dialect": "sqlite",
|
||||
"entries": [
|
||||
{
|
||||
"idx": 0,
|
||||
"version": "6",
|
||||
"when": 1721758030188,
|
||||
"tag": "0000_hot_thunderball",
|
||||
"breakpoints": true
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -4,5 +4,6 @@ import { sql } from 'drizzle-orm'
|
||||
export const users = sqliteTable('users', {
|
||||
id: integer('id').primaryKey(),
|
||||
name: text('name').default(''),
|
||||
email: text('email').default(''),
|
||||
createdAt: text('created_at').default(sql`(CURRENT_DATE)`),
|
||||
})
|
||||
|
||||
18
server/routes/auth/github.get.ts
Normal file
18
server/routes/auth/github.get.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
export default oauthGitHubEventHandler({
|
||||
config: {
|
||||
emailRequired: true,
|
||||
},
|
||||
async onSuccess(event, { user }) {
|
||||
await setUserSession(event, {
|
||||
user: {
|
||||
email: user.email,
|
||||
name: user.name,
|
||||
},
|
||||
})
|
||||
return sendRedirect(event, '/home')
|
||||
},
|
||||
onError(event, error) {
|
||||
console.error('GitHub OAuth error:', error)
|
||||
return sendRedirect(event, '/')
|
||||
},
|
||||
})
|
||||
6
auth.d.ts → types/auth.d.ts
vendored
6
auth.d.ts → types/auth.d.ts
vendored
@@ -1,11 +1,13 @@
|
||||
// auth.d.ts
|
||||
declare module '#auth-utils' {
|
||||
interface User {
|
||||
// Add your own fields
|
||||
email: string
|
||||
name: string
|
||||
}
|
||||
|
||||
interface UserSession {
|
||||
// Add your own fields
|
||||
email: string
|
||||
name: string
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user