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()}
|
||||
@@ -2,7 +2,14 @@
|
||||
import { getCurrentUser, ObtenerGruposDeUsuario } from '$lib/api';
|
||||
import CardError from '$lib/components/CardError.svelte';
|
||||
import Header from '$lib/components/Header.svelte';
|
||||
import { Accordion, AccordionItem, Loading, Tile } from 'carbon-components-svelte';
|
||||
import {
|
||||
Accordion,
|
||||
AccordionItem,
|
||||
ContainedList,
|
||||
ContainedListItem,
|
||||
Loading,
|
||||
Tile
|
||||
} from 'carbon-components-svelte';
|
||||
|
||||
let usuario = getCurrentUser();
|
||||
|
||||
@@ -28,9 +35,13 @@
|
||||
{#if g.permisos?.length == 0}
|
||||
<p class="text-neutral-500">No hay permisos en este grupo</p>
|
||||
{:else}
|
||||
{#each g.permisos as p}
|
||||
<a href={p.alias}>{p.nombre}</a>
|
||||
{/each}
|
||||
<ContainedList>
|
||||
{#each g.permisos as p}
|
||||
<ContainedListItem>
|
||||
<a href={p.alias}>{p.nombre}</a>
|
||||
</ContainedListItem>
|
||||
{/each}
|
||||
</ContainedList>
|
||||
{/if}
|
||||
</AccordionItem>
|
||||
{/each}
|
||||
|
||||
Reference in new issue
Block a user