aboutsummaryrefslogtreecommitdiffstats
path: root/src/routes/logout
diff options
context:
space:
mode:
Diffstat (limited to 'src/routes/logout')
-rw-r--r--src/routes/logout/done.svelte13
-rw-r--r--src/routes/logout/index.js26
-rw-r--r--src/routes/logout/index.svelte10
3 files changed, 49 insertions, 0 deletions
diff --git a/src/routes/logout/done.svelte b/src/routes/logout/done.svelte
new file mode 100644
index 00000000..fe526357
--- /dev/null
+++ b/src/routes/logout/done.svelte
@@ -0,0 +1,13 @@
+<script>
+ import { onMount } from 'svelte';
+ import { user, token } from '$lib/store';
+ import { goto } from '$app/navigation';
+ import { close } from '$lib/socket';
+
+ onMount(() => {
+ $token = null;
+ $user = null;
+ close();
+ });
+ goto('/');
+</script>
diff --git a/src/routes/logout/index.js b/src/routes/logout/index.js
new file mode 100644
index 00000000..6cbae8f2
--- /dev/null
+++ b/src/routes/logout/index.js
@@ -0,0 +1,26 @@
+import cookie from 'cookie';
+
+const opts = {
+ httpOnly: true,
+ sameSite: 'lax',
+ path: '/'
+};
+
+export async function GET({ request: { headers } }) {
+ return {
+ status: 302,
+ headers: {
+ location: '/logout/done',
+ 'set-cookie': [
+ cookie.serialize('token', '', {
+ ...opts,
+ expires: new Date(0)
+ }),
+ cookie.serialize('refresh_token', '', {
+ ...opts,
+ expires: new Date(0)
+ })
+ ]
+ }
+ };
+}
diff --git a/src/routes/logout/index.svelte b/src/routes/logout/index.svelte
new file mode 100644
index 00000000..2c6a7085
--- /dev/null
+++ b/src/routes/logout/index.svelte
@@ -0,0 +1,10 @@
+<script>
+ import { onMount } from 'svelte';
+ import { browser } from '$app/env';
+ import { user, token } from '$lib/store';
+
+ onMount(() => {
+ $user = null;
+ $token = null;
+ });
+</script>