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)
}
/**