-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0882625
commit 2b432fe
Showing
6 changed files
with
46 additions
and
5 deletions.
There are no files selected for viewing
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,14 @@ | ||
<a href="/logout">Logout</a> | ||
|
||
<style> | ||
a { | ||
color: white; | ||
background-color: dimgray; | ||
border: 3px solid black; | ||
text-decoration: none; | ||
text-transform: uppercase; | ||
padding: 10px; | ||
border-radius: 5px; | ||
font-family: "Arial Black", "Arial Bold", Gadget, sans-serif; | ||
} | ||
</style> |
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,2 @@ | ||
export const SESSION_COOKIE_KEY = "session"; | ||
export const SESSION_DURATION_DAYS = 7; |
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,9 @@ | ||
<script lang="ts"> | ||
import type { LayoutData } from "./$types"; | ||
import LogoutButton from "$lib/LogoutButton.svelte"; | ||
export let data: LayoutData; | ||
</script> | ||
|
||
You are currently logged in as {data.user.name} | ||
<p>You are currently logged in as {data.user.name}</p> | ||
<LogoutButton /> |
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,23 @@ | ||
import { SESSION_COOKIE_KEY } from "$lib/constants"; | ||
import prisma from "$lib/prisma"; | ||
import { toBuffer } from "uuid-buffer"; | ||
import type { RequestHandler } from "@sveltejs/kit"; | ||
|
||
export const GET: RequestHandler = async ({ cookies }) => { | ||
const session_uuid = cookies.get(SESSION_COOKIE_KEY); | ||
if (session_uuid) { | ||
await prisma.session.update({ | ||
data: { | ||
expires: new Date(), | ||
}, | ||
where: { | ||
uuid_bin: toBuffer(session_uuid), | ||
}, | ||
}); | ||
cookies.delete(SESSION_COOKIE_KEY); | ||
} | ||
return new Response("Redirect", { | ||
status: 303, | ||
headers: { Location: "/login" }, | ||
}); | ||
}; |