Files
Generadordeguiones/frontend/src/stores/auth.js
Hanzo_dev 9dafed72eb 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>
2026-03-31 08:31:40 -05:00

27 lines
676 B
JavaScript

import { defineStore } from 'pinia'
import { ref } from 'vue'
const ADMIN_EMAIL = 'admin@gmail.com'
const ADMIN_PASSWORD = 'admin123'
const STORAGE_KEY = 'auth_session'
export const useAuthStore = defineStore('auth', () => {
const isAuthenticated = ref(!!localStorage.getItem(STORAGE_KEY))
function login(email, password) {
if (email === ADMIN_EMAIL && password === ADMIN_PASSWORD) {
localStorage.setItem(STORAGE_KEY, '1')
isAuthenticated.value = true
return true
}
return false
}
function logout() {
localStorage.removeItem(STORAGE_KEY)
isAuthenticated.value = false
}
return { isAuthenticated, login, logout }
})