feat: implement user consent verification and redirection for LGPD compliance in dashboard layout and consent term page
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { resolve } from '$app/paths';
|
||||
import { page } from '$app/state';
|
||||
import { Shield, CheckCircle, AlertCircle, FileText } from 'lucide-svelte';
|
||||
import { useQuery, useMutation } from 'convex-svelte';
|
||||
import { api } from '@sgse-app/backend/convex/_generated/api';
|
||||
@@ -21,6 +22,18 @@
|
||||
const termoObrigatorio = $derived(consentimentoQuery?.data?.termoObrigatorio ?? false);
|
||||
const versaoTermoAtual = $derived(consentimentoQuery?.data?.versaoTermoAtual ?? '1.0');
|
||||
|
||||
// Rota de retorno após aceite
|
||||
const redirectTo = $derived(page.url.searchParams.get('redirect') || '/');
|
||||
|
||||
function navegarDeVolta() {
|
||||
// Se vier algo como URL absoluta, mantemos; senão usamos resolve
|
||||
if (redirectTo.startsWith('/')) {
|
||||
window.location.href = redirectTo;
|
||||
} else {
|
||||
window.location.href = resolve(redirectTo);
|
||||
}
|
||||
}
|
||||
|
||||
async function aceitarTermo() {
|
||||
if (termoObrigatorio && !aceito) {
|
||||
erro = 'Você precisa aceitar o termo para continuar';
|
||||
@@ -29,7 +42,7 @@
|
||||
|
||||
if (!aceito) {
|
||||
// Se não é obrigatório e não aceitou, apenas redireciona
|
||||
window.location.href = resolve('/');
|
||||
navegarDeVolta();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -43,6 +56,7 @@
|
||||
versao: versaoTermoAtual
|
||||
});
|
||||
sucesso = true;
|
||||
navegarDeVolta();
|
||||
} catch (e: unknown) {
|
||||
erro = e instanceof Error ? e.message : 'Erro ao registrar consentimento';
|
||||
} finally {
|
||||
@@ -102,9 +116,9 @@
|
||||
<p class="text-base-content/80 mb-6">
|
||||
Seu consentimento foi registrado. Você pode acessar o sistema normalmente.
|
||||
</p>
|
||||
<a href={resolve('/')} class="btn btn-primary btn-lg">
|
||||
<button type="button" class="btn btn-primary btn-lg" onclick={navegarDeVolta}>
|
||||
Continuar para o Sistema
|
||||
</a>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
{:else}
|
||||
|
||||
Reference in New Issue
Block a user