feat: sistema de autenticación con login, logout y guard de rutas

- Agrega LoginView con formulario de acceso
- Agrega store de auth (Pinia) con estado isAuthenticated
- Protege todas las rutas con beforeEach, redirige a /login si no autenticado
- App.vue oculta nav/sidebar en rutas públicas
- TopAppBar incluye botón de cerrar sesión

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-31 08:31:40 -05:00
parent e4c2602686
commit 9dafed72eb
5 changed files with 183 additions and 13 deletions

View File

@ -1,24 +1,35 @@
<template>
<div class="bg-canvas min-h-screen text-ink selection:bg-accent/20 selection:text-accent">
<SideNavBar />
<TopAppBar />
<!-- Área principal -->
<main class="ml-60 pt-16 pb-12 px-8 min-h-screen">
<div class="max-w-7xl mx-auto pt-8">
<router-view v-slot="{ Component }">
<transition name="fade" mode="out-in">
<component :is="Component" />
</transition>
</router-view>
</div>
</main>
<template v-if="isAuthenticated">
<SideNavBar />
<TopAppBar />
<main class="ml-60 pt-16 pb-12 px-8 min-h-screen">
<div class="max-w-7xl mx-auto pt-8">
<router-view v-slot="{ Component }">
<transition name="fade" mode="out-in">
<component :is="Component" />
</transition>
</router-view>
</div>
</main>
</template>
<template v-else>
<router-view />
</template>
</div>
</template>
<script setup>
import { storeToRefs } from 'pinia'
import { useAuthStore } from './stores/auth.js'
import SideNavBar from './components/SideNavBar.vue'
import TopAppBar from './components/TopAppBar.vue'
const auth = useAuthStore()
const { isAuthenticated } = storeToRefs(auth)
</script>
<style>