From 1b51fe65b52c0f1e578e27dd0ca2f39cbc829b9d Mon Sep 17 00:00:00 2001 From: consultoria-as Date: Thu, 2 Jul 2026 22:27:50 +0000 Subject: [PATCH] fix(pos): hide Sistema button for non-admin roles and allow login/logout in page guard --- pos/static/js/app-init.js | 12 ++++++++++++ pos/templates/accounting.html | 2 +- pos/templates/catalog.html | 2 +- pos/templates/config.html | 2 +- pos/templates/customers.html | 2 +- pos/templates/dashboard.html | 2 +- pos/templates/diagrams.html | 2 +- pos/templates/fleet.html | 2 +- pos/templates/inventory.html | 2 +- pos/templates/invoicing.html | 2 +- pos/templates/marketplace_external.html | 2 +- pos/templates/pos.html | 2 +- pos/templates/quotations.html | 2 +- pos/templates/remission_notes.html | 2 +- pos/templates/reports.html | 2 +- pos/templates/supplier_catalog.html | 2 +- pos/templates/whatsapp.html | 2 +- pos/templates/workshop.html | 2 +- 18 files changed, 29 insertions(+), 17 deletions(-) diff --git a/pos/static/js/app-init.js b/pos/static/js/app-init.js index 2dc5996..170afdf 100644 --- a/pos/static/js/app-init.js +++ b/pos/static/js/app-init.js @@ -221,6 +221,9 @@ return ['/pos/sale','/pos/catalog','/pos/inventory','/pos/customers','/pos/workshop','/pos/remission-notes','/pos/invoicing','/pos/reports'].indexOf(pagePath) !== -1; } + // Always allow login/logout pages so users can sign out without hitting the guard. + if (pagePath === '/pos/login' || pagePath === '/pos/logout') return true; + // Any other role (accountant, warehouse, sales, etc.) keeps the previous permissive behavior. return true; } @@ -280,6 +283,15 @@ }).catch(function() {}); } catch(e) {} + // ─── Hide POS "Sistema" button for roles that cannot access the dashboard ─── + (function hideBackToSystemForRestrictedRoles() { + var backBtn = document.getElementById('backToSystemBtn'); + if (!backBtn) return; + // owner/admin are the only roles that should see the dashboard shortcut from POS. + if (role === 'owner' || role === 'admin') return; + backBtn.style.display = 'none'; + })(); + // ─── Service Worker update handler ─── if ('serviceWorker' in navigator) { navigator.serviceWorker.addEventListener('message', function (event) { diff --git a/pos/templates/accounting.html b/pos/templates/accounting.html index 59ab40c..469fcf6 100644 --- a/pos/templates/accounting.html +++ b/pos/templates/accounting.html @@ -493,7 +493,7 @@ - + diff --git a/pos/templates/catalog.html b/pos/templates/catalog.html index cf83bab..1e6d51a 100644 --- a/pos/templates/catalog.html +++ b/pos/templates/catalog.html @@ -316,7 +316,7 @@ - + diff --git a/pos/templates/config.html b/pos/templates/config.html index c24e4e0..e50f453 100644 --- a/pos/templates/config.html +++ b/pos/templates/config.html @@ -1016,7 +1016,7 @@ - + diff --git a/pos/templates/customers.html b/pos/templates/customers.html index 4d81d13..6a1bf2b 100644 --- a/pos/templates/customers.html +++ b/pos/templates/customers.html @@ -651,7 +651,7 @@ - + diff --git a/pos/templates/dashboard.html b/pos/templates/dashboard.html index b1aed47..1dbf2db 100644 --- a/pos/templates/dashboard.html +++ b/pos/templates/dashboard.html @@ -606,7 +606,7 @@ - + diff --git a/pos/templates/diagrams.html b/pos/templates/diagrams.html index 714177e..4a35f11 100644 --- a/pos/templates/diagrams.html +++ b/pos/templates/diagrams.html @@ -150,7 +150,7 @@ - + diff --git a/pos/templates/fleet.html b/pos/templates/fleet.html index 7517ce3..6bb9ddf 100644 --- a/pos/templates/fleet.html +++ b/pos/templates/fleet.html @@ -303,7 +303,7 @@ - + diff --git a/pos/templates/inventory.html b/pos/templates/inventory.html index bbfebd3..ea1cc84 100644 --- a/pos/templates/inventory.html +++ b/pos/templates/inventory.html @@ -1062,7 +1062,7 @@ - + diff --git a/pos/templates/invoicing.html b/pos/templates/invoicing.html index 321c86a..17da913 100644 --- a/pos/templates/invoicing.html +++ b/pos/templates/invoicing.html @@ -1064,7 +1064,7 @@ - + diff --git a/pos/templates/marketplace_external.html b/pos/templates/marketplace_external.html index 9231a32..4b8b94b 100644 --- a/pos/templates/marketplace_external.html +++ b/pos/templates/marketplace_external.html @@ -343,7 +343,7 @@ - + diff --git a/pos/templates/pos.html b/pos/templates/pos.html index a835e34..259c757 100644 --- a/pos/templates/pos.html +++ b/pos/templates/pos.html @@ -729,7 +729,7 @@ - + diff --git a/pos/templates/quotations.html b/pos/templates/quotations.html index 96bf8e6..45e5004 100644 --- a/pos/templates/quotations.html +++ b/pos/templates/quotations.html @@ -15,7 +15,7 @@ - + diff --git a/pos/templates/remission_notes.html b/pos/templates/remission_notes.html index e8d69a4..d3a5b5c 100644 --- a/pos/templates/remission_notes.html +++ b/pos/templates/remission_notes.html @@ -227,7 +227,7 @@ - + - + diff --git a/pos/templates/supplier_catalog.html b/pos/templates/supplier_catalog.html index fe57b45..2286bc4 100644 --- a/pos/templates/supplier_catalog.html +++ b/pos/templates/supplier_catalog.html @@ -126,7 +126,7 @@ - + diff --git a/pos/templates/whatsapp.html b/pos/templates/whatsapp.html index c59ac0e..2775915 100644 --- a/pos/templates/whatsapp.html +++ b/pos/templates/whatsapp.html @@ -132,7 +132,7 @@ function posLogout(){localStorage.removeItem('pos_token');window.location.href=' - + diff --git a/pos/templates/workshop.html b/pos/templates/workshop.html index 6ec9bb4..9633b31 100644 --- a/pos/templates/workshop.html +++ b/pos/templates/workshop.html @@ -494,7 +494,7 @@ - +