diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index 3042566..743062d 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -1,13 +1,6 @@ diff --git a/src/routes/+page.server.js b/src/routes/+page.server.js index e406372..f22847e 100644 --- a/src/routes/+page.server.js +++ b/src/routes/+page.server.js @@ -1,26 +1,27 @@ import { fail, redirect } from '@sveltejs/kit'; +export async function load({ cookies }) { + if (cookies.get("mToken")) { + redirect(302, '/emotes'); + } +} export const actions = { - default: async ({ request, cookies }) => { - //if (cookies.get('matrixToken')) { - // redirect(302, '/emotes'); - //} + default: async ({ cookies, request }) => { + if (cookies.get("mToken")) { + redirect(302, '/emotes'); + } + const data = await request.formData(); - const homeserver = data.get('url'); - const username = data.get('username'); - const password = data.get('password'); - let token = ""; + const token = data.get("token"); + const homeserver = data.get("hs"); + + if(!homeserver || !token) return fail(400, "Invalid credentials"); - if(!homeserver || !username || !password ) return fail(400, "Invalid credentials"); + + cookies.set('mToken', token, { path: "/" }); + cookies.set('hs', homeserver, { path: "/" }); - cookies.set( - 'matrixToken', token, { - path: '/', - maxAge: 60 * 60 * 24 * 365, - httpOnly: false - }, - ); - redirect(302, '/'); + return redirect(302, '/emotes') } -} \ No newline at end of file +}; \ No newline at end of file diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index ba4c550..b2bebd9 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -1,8 +1,7 @@
@@ -31,7 +39,7 @@

Sign in to your Matrix Account

-
+
@@ -45,7 +53,7 @@
- +
diff --git a/src/routes/emotes/+layout.svelte b/src/routes/emotes/+layout.svelte new file mode 100644 index 0000000..3ba231c --- /dev/null +++ b/src/routes/emotes/+layout.svelte @@ -0,0 +1,5 @@ + + + \ No newline at end of file diff --git a/src/routes/emotes/+page.server.js b/src/routes/emotes/+page.server.js new file mode 100644 index 0000000..43a27ec --- /dev/null +++ b/src/routes/emotes/+page.server.js @@ -0,0 +1,6 @@ +export const load = (async ({ cookies}) => { + const homeserver = cookies.get("hs"); + const token = cookies.get("mToken"); + + return { homeserver: homeserver, token: token} +}) \ No newline at end of file diff --git a/src/routes/emotes/+page.svelte b/src/routes/emotes/+page.svelte index 087340c..4cad14f 100644 --- a/src/routes/emotes/+page.svelte +++ b/src/routes/emotes/+page.svelte @@ -1,24 +1,29 @@