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">
|
||||
import "../app.postcss";
|
||||
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";
|
||||
|
||||
function signOut() {
|
||||
authSignOut().then(session.set);
|
||||
}
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
@ -191,7 +195,7 @@
|
||||
"items-center",
|
||||
"flex-col",
|
||||
"bg-orange-600",
|
||||
"text-white"
|
||||
"text-white",
|
||||
)}
|
||||
>
|
||||
<span>© RaviAnand M, 2021</span>
|
||||
|
@ -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=. ."
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
||||
return signout === true;
|
||||
if (!signout) {
|
||||
throw new Error("Sign out not successful!");
|
||||
}
|
||||
|
||||
res = await fetch("/api/auth/session");
|
||||
const session = await res.json();
|
||||
|
||||
return session;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user