diff --git a/src/components/App.vue b/src/components/App.vue index bd11852..d8ffbed 100644 --- a/src/components/App.vue +++ b/src/components/App.vue @@ -1,33 +1,12 @@ diff --git a/src/pages/POS/Factura/Index.vue b/src/pages/POS/Factura/Index.vue index dd474a0..258c223 100644 --- a/src/pages/POS/Factura/Index.vue +++ b/src/pages/POS/Factura/Index.vue @@ -126,7 +126,7 @@ onMounted(() => {
-

+

Solicitud de Factura

@@ -140,7 +140,7 @@ onMounted(() => { -

+
@@ -153,7 +153,7 @@ onMounted(() => {
-
+
@@ -176,7 +176,7 @@ onMounted(() => { Datos de la Venta -
+
Folio: {{ saleData.invoice_number }} diff --git a/src/router/Index.js b/src/router/Index.js index 24fe217..cb2a3b9 100644 --- a/src/router/Index.js +++ b/src/router/Index.js @@ -1,5 +1,6 @@ import { createRouter, createWebHashHistory } from 'vue-router' import { hasPermission } from '@Plugins/RolePermission'; +import { hasToken } from '@Services/Api'; import examples from './Examples'; @@ -237,4 +238,26 @@ const router = createRouter({ ] }) +router.beforeEach((to, from, next) => { + const publicRoutes = [ + 'facturacion.index', + 'auth.index', + 'auth.forgot-password', + 'auth.reset-password' + ]; + + // Si es una ruta pública, permitir acceso + if (publicRoutes.includes(to.name)) { + return next(); + } + + // Si no es pública y no hay token, redirigir a login + if (!hasToken()) { + return next({ name: 'auth.index' }); + } + + // Si hay token, permitir acceso + next(); +}); + export default router diff --git a/src/services/Api.js b/src/services/Api.js index 7b7b74c..643bc99 100644 --- a/src/services/Api.js +++ b/src/services/Api.js @@ -73,6 +73,10 @@ const closeSession = () => { resetCsrfToken() Notify.info(Lang('session.closed')) + + setTimeout(() => { + window.location.hash = '#/auth' + }, 500) } /**