-
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
Showing
6 changed files
with
146 additions
and
12 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
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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<style> | ||
.content { | ||
position: fixed; | ||
left: 0; | ||
right: 0; | ||
top: 0; | ||
bottom: 0; | ||
overflow-x: hidden; | ||
padding: 1rem; | ||
display: grid; | ||
justify-content: center; | ||
align-content: center; | ||
} | ||
</style> | ||
|
||
<script> | ||
let sending = false | ||
let count = 0 | ||
async function destroy() { | ||
sending = true | ||
await fetch('/session/destroy') | ||
count++ | ||
sending = false | ||
} | ||
</script> | ||
|
||
<div class="content"> | ||
<button disabled={sending} on:mouseup={destroy}> | ||
<span>Destroy</span> | ||
</button> | ||
{#if sending} | ||
<span>Destroying session...</span> | ||
{:else if count > 0} | ||
<span>Done.</span> | ||
{/if} | ||
</div> |
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,29 @@ | ||
import { session } from '$lib/session' | ||
|
||
/** | ||
* | ||
* @param {number} milliseconds | ||
* @returns {Promise<void>} | ||
*/ | ||
function delay(milliseconds) { | ||
return new Promise(function start(resolve) { | ||
setTimeout(resolve, milliseconds) | ||
}) | ||
} | ||
|
||
export async function GET({ cookies }) { | ||
const { | ||
error, | ||
value: { destroy }, | ||
} = await session.start({ cookies }) | ||
|
||
if (error) { | ||
return new Response(error.message, { status: 500 }) | ||
} | ||
|
||
await destroy() | ||
|
||
await delay(3000) | ||
|
||
return new Response('Session destroyed.') | ||
} |