From 746cbdcf73d0163cc71275e709de31e79f4be81a Mon Sep 17 00:00:00 2001 From: RaviAnand Mohabir Date: Sun, 23 May 2021 17:21:01 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Remove=20usage=20of=20SvelteKit?= =?UTF-8?q?=20modules?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Disable implicitly updating session, routing and getting redirect URL from SvelteKit modules due to missing exports. --- app/src/routes/__layout.svelte | 8 ++++++-- package.json | 2 +- src/client/signIn.ts | 8 ++++---- src/client/signOut.ts | 15 +++++++++------ 4 files changed, 20 insertions(+), 13 deletions(-) diff --git a/app/src/routes/__layout.svelte b/app/src/routes/__layout.svelte index 068e441..a471b5a 100644 --- a/app/src/routes/__layout.svelte +++ b/app/src/routes/__layout.svelte @@ -1,8 +1,12 @@ @@ -191,7 +195,7 @@ "items-center", "flex-col", "bg-orange-600", - "text-white" + "text-white", )} > © RaviAnand M, 2021 diff --git a/package.json b/package.json index f3f98a2..8be4676 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ ], "scripts": { "build": "rollup --config", - "dev": "rollup --watch", + "dev": "rollup --config --watch", "test": "echo \"Error: no test specified\" && exit 1", "lint": "prettier --check --plugin-search-dir=. . && eslint --ignore-path .gitignore .", "format": "prettier --write --plugin-search-dir=. ." diff --git a/src/client/signIn.ts b/src/client/signIn.ts index 1844100..7cc3ba3 100644 --- a/src/client/signIn.ts +++ b/src/client/signIn.ts @@ -1,5 +1,5 @@ -import { goto } from "@sveltejs/kit/assets/runtime/app/navigation"; -import { page } from "@sveltejs/kit/assets/runtime/app/stores"; +/* import { goto } from "@sveltejs/kit/assets/runtime/app/navigation"; +import { page } from "@sveltejs/kit/assets/runtime/app/stores"; */ import type { Page } from "@sveltejs/kit"; interface SignInConfig { @@ -24,7 +24,7 @@ export async function signIn(provider: string, data?: any, config?: SignInConfig redirectUrl = config.redirectUrl; } else { let $val: Page | undefined; - page.subscribe(($) => ($val = $))(); + /* page.subscribe(($) => ($val = $))(); */ if ($val) { redirectUrl = `${$val.host}${$val.path}?${$val.query}`; } @@ -36,5 +36,5 @@ export async function signIn(provider: string, data?: any, config?: SignInConfig const query = new URLSearchParams(queryData); const path = `/api/auth/login/${provider}?${query}`; - return await goto(path); + return path; // await goto(path); } diff --git a/src/client/signOut.ts b/src/client/signOut.ts index 564ab69..a6d91cf 100644 --- a/src/client/signOut.ts +++ b/src/client/signOut.ts @@ -1,12 +1,15 @@ -import { session as session$ } from "$app/stores"; +/* import { session as session$ } from "$app/stores"; */ export async function signOut() { - const res = await fetch("/api/auth/signout", { method: "POST" }); + let res = await fetch("/api/auth/signout", { method: "POST" }); const { signout } = await res.json(); - fetch("/api/auth/session") - .then((res) => res.json()) - .then(session$.set); + if (!signout) { + throw new Error("Sign out not successful!"); + } - return signout === true; + res = await fetch("/api/auth/session"); + const session = await res.json(); + + return session; }