mirror of
https://github.com/Dan6erbond/sk-auth.git
synced 2025-09-14 17:50:30 +02:00
🐛 Remove usage of SvelteKit modules
Disable implicitly updating session, routing and getting redirect URL from SvelteKit modules due to missing exports.
This commit is contained in:
parent
2d48b1759c
commit
746cbdcf73
@ -1,8 +1,12 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import "../app.postcss";
|
import "../app.postcss";
|
||||||
import { page, session } from "$app/stores";
|
import { page, session } from "$app/stores";
|
||||||
import { signOut } from "svelte-kit-auth/client";
|
import { signOut as authSignOut } from "svelte-kit-auth/client";
|
||||||
import clsx from "clsx";
|
import clsx from "clsx";
|
||||||
|
|
||||||
|
function signOut() {
|
||||||
|
authSignOut().then(session.set);
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:head>
|
<svelte:head>
|
||||||
@ -191,7 +195,7 @@
|
|||||||
"items-center",
|
"items-center",
|
||||||
"flex-col",
|
"flex-col",
|
||||||
"bg-orange-600",
|
"bg-orange-600",
|
||||||
"text-white"
|
"text-white",
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<span>© RaviAnand M, 2021</span>
|
<span>© RaviAnand M, 2021</span>
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "rollup --config",
|
"build": "rollup --config",
|
||||||
"dev": "rollup --watch",
|
"dev": "rollup --config --watch",
|
||||||
"test": "echo \"Error: no test specified\" && exit 1",
|
"test": "echo \"Error: no test specified\" && exit 1",
|
||||||
"lint": "prettier --check --plugin-search-dir=. . && eslint --ignore-path .gitignore .",
|
"lint": "prettier --check --plugin-search-dir=. . && eslint --ignore-path .gitignore .",
|
||||||
"format": "prettier --write --plugin-search-dir=. ."
|
"format": "prettier --write --plugin-search-dir=. ."
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { goto } from "@sveltejs/kit/assets/runtime/app/navigation";
|
/* import { goto } from "@sveltejs/kit/assets/runtime/app/navigation";
|
||||||
import { page } from "@sveltejs/kit/assets/runtime/app/stores";
|
import { page } from "@sveltejs/kit/assets/runtime/app/stores"; */
|
||||||
import type { Page } from "@sveltejs/kit";
|
import type { Page } from "@sveltejs/kit";
|
||||||
|
|
||||||
interface SignInConfig {
|
interface SignInConfig {
|
||||||
@ -24,7 +24,7 @@ export async function signIn(provider: string, data?: any, config?: SignInConfig
|
|||||||
redirectUrl = config.redirectUrl;
|
redirectUrl = config.redirectUrl;
|
||||||
} else {
|
} else {
|
||||||
let $val: Page | undefined;
|
let $val: Page | undefined;
|
||||||
page.subscribe(($) => ($val = $))();
|
/* page.subscribe(($) => ($val = $))(); */
|
||||||
if ($val) {
|
if ($val) {
|
||||||
redirectUrl = `${$val.host}${$val.path}?${$val.query}`;
|
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 query = new URLSearchParams(queryData);
|
||||||
const path = `/api/auth/login/${provider}?${query}`;
|
const path = `/api/auth/login/${provider}?${query}`;
|
||||||
|
|
||||||
return await goto(path);
|
return path; // await goto(path);
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,15 @@
|
|||||||
import { session as session$ } from "$app/stores";
|
/* import { session as session$ } from "$app/stores"; */
|
||||||
|
|
||||||
export async function signOut() {
|
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();
|
const { signout } = await res.json();
|
||||||
|
|
||||||
fetch("/api/auth/session")
|
if (!signout) {
|
||||||
.then((res) => res.json())
|
throw new Error("Sign out not successful!");
|
||||||
.then(session$.set);
|
}
|
||||||
|
|
||||||
return signout === true;
|
res = await fetch("/api/auth/session");
|
||||||
|
const session = await res.json();
|
||||||
|
|
||||||
|
return session;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user