Private
Public Access
feat: refrescador de tokens
This commit is contained in:
1 parent
0ca9e34801
commit
936a401816
4 files changed
+125
-9
No files matched your search
@@ -4,6 +4,7 @@
|
||||
import favicon from '$lib/assets/favicon.svg';
|
||||
import { getToken } from '$lib/api';
|
||||
import { goto } from '$app/navigation';
|
||||
import { TokenRefresher } from '$lib/TokenRefresher.svelte';
|
||||
|
||||
let { children } = $props();
|
||||
let theme = 'g100'; // "white" | "g10" | "g80" | "g90" | "g100"
|
||||
@@ -18,8 +19,20 @@
|
||||
$effect(() => {
|
||||
document.documentElement.setAttribute('theme', theme);
|
||||
});
|
||||
|
||||
let _refresher: TokenRefresher;
|
||||
|
||||
$effect(() => {
|
||||
if (token) {
|
||||
_refresher = new TokenRefresher(() => {
|
||||
token = '';
|
||||
goto('/login');
|
||||
});
|
||||
}
|
||||
return () => _refresher?.stop();
|
||||
});
|
||||
</script>
|
||||
|
||||
<svelte:head><link rel="icon" href={favicon} /></svelte:head>
|
||||
|
||||
<button onclick={() => _refresher.refresh()} style="margin-top: 8rem;">ghola</button>
|
||||
{@render children()}
|
||||
Reference in new issue
Block a user