-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ feat: add base pages and auth (#14)
* 🚧 wip: add mongoose * fix: 🐛 mongoose adapter/callback * refactor: ♻️ use mongoose on client end * chore: 🔨 remove unused code * 🚧 wip: test permissions * 🚧 wip: test permissions * 🚧 wip: test permissions * 🚧 wip: test permissions * 🚧 wip: test permissions * ✨ feat: add error sections * 🧑💻 chore: remove console.logs --------- Co-authored-by: slugb0t <wheresdorian@gmail.com>
- Loading branch information
1 parent
1f7b6bc
commit 384e981
Showing
21 changed files
with
1,396 additions
and
337 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<script setup lang="ts"></script> | ||
|
||
<template> | ||
<NuxtLayout name="default"> | ||
<main class="grid place-items-center px-6 lg:px-8"> | ||
<div class="text-center"> | ||
<img | ||
src="/assets/images/error/404.svg" | ||
alt="Page not found" | ||
class="mx-auto w-96" | ||
/> | ||
|
||
<h1 | ||
class="mt-4 text-3xl font-bold tracking-tight text-gray-900 sm:text-5xl" | ||
> | ||
Something went wrong | ||
</h1> | ||
|
||
<p class="mt-6 text-base leading-7 text-gray-600"> | ||
The page you are looking for might have been removed or is temporarily | ||
unavailable. | ||
</p> | ||
</div> | ||
</main> | ||
</NuxtLayout> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
export default defineNuxtRouteMiddleware(async () => { | ||
const user = useUser(); | ||
|
||
if (!user.value) { | ||
return navigateTo("/login"); | ||
} | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,15 @@ | ||
export default eventHandler(async (event) => { | ||
if (!event.context.session) { | ||
throw createError({ | ||
statusCode: 403 | ||
}); | ||
} | ||
await lucia.invalidateSession(event.context.session.id); | ||
appendHeader(event, "Set-Cookie", lucia.createBlankSessionCookie().serialize()); | ||
if (!event.context.session) { | ||
throw createError({ | ||
statusCode: 403, | ||
}); | ||
} | ||
|
||
await lucia.invalidateSession(event.context.session.id); | ||
|
||
appendHeader( | ||
event, | ||
"Set-Cookie", | ||
lucia.createBlankSessionCookie().serialize(), | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,13 @@ | ||
export default defineEventHandler((event) => { | ||
return event.context.user; | ||
import type { User } from "lucia"; | ||
|
||
export default defineEventHandler(async (event) => { | ||
const user = event.context.user as User | null; | ||
|
||
return user | ||
? { | ||
username: user?.username, | ||
githubId: user?.github_id, | ||
id: user?.id, | ||
} | ||
: null; | ||
}); |
Oops, something went wrong.