로그인 페이지에서 Token Refresh 성공시의 자동 리다이렉션 구현

This commit is contained in:
static
2024-12-29 23:31:33 +09:00
parent 4a10ba0fbf
commit 95bad90f36
2 changed files with 10 additions and 1 deletions

View File

@@ -1,4 +1,4 @@
const refreshToken = async () => { export const refreshToken = async () => {
return await fetch("/api/auth/refreshToken", { method: "POST" }); return await fetch("/api/auth/refreshToken", { method: "POST" });
}; };

View File

@@ -1,8 +1,10 @@
<script lang="ts"> <script lang="ts">
import { onMount } from "svelte";
import { goto } from "$app/navigation"; import { goto } from "$app/navigation";
import { Button, TextButton } from "$lib/components/buttons"; import { Button, TextButton } from "$lib/components/buttons";
import { TitleDiv, BottomDiv } from "$lib/components/divs"; import { TitleDiv, BottomDiv } from "$lib/components/divs";
import { TextInput } from "$lib/components/inputs"; import { TextInput } from "$lib/components/inputs";
import { refreshToken } from "$lib/hooks/callAPI";
import { keyPairStore } from "$lib/stores"; import { keyPairStore } from "$lib/stores";
import { requestLogin } from "./service"; import { requestLogin } from "./service";
@@ -24,6 +26,13 @@
// TODO: Alert // TODO: Alert
} }
}; };
onMount(async () => {
const res = await refreshToken();
if (res.ok) {
await goto(data.redirectPath);
}
});
</script> </script>
<svelte:head> <svelte:head>