mirror of
https://github.com/kmc7468/arkvault.git
synced 2025-12-17 23:48:45 +00:00
암호 키 유무에 따른 자동 리다이렉션 구현
This commit is contained in:
@@ -1,6 +1,22 @@
|
||||
<script lang="ts">
|
||||
import { onMount } from "svelte";
|
||||
import { goto } from "$app/navigation";
|
||||
import { getKeyPairFromIndexedDB } from "$lib/indexedDB";
|
||||
import { keyPairStore } from "$lib/stores";
|
||||
import "../app.css";
|
||||
|
||||
let { children } = $props();
|
||||
|
||||
onMount(async () => {
|
||||
const { pubKey, privKey } = await getKeyPairFromIndexedDB();
|
||||
if (pubKey && privKey) {
|
||||
keyPairStore.set({ publicKey: pubKey, privateKey: privKey });
|
||||
} else if (!["/auth", "/key/generate"].some((path) => location.pathname.startsWith(path))) {
|
||||
await goto(
|
||||
"/key/generate?redirect=" + encodeURIComponent(location.pathname + location.search),
|
||||
);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
{@render children()}
|
||||
|
||||
Reference in New Issue
Block a user