fix(pos): hide Sistema button for non-admin roles and allow login/logout in page guard
Some checks failed
CI / lint-and-test (3.11) (push) Has been cancelled
CI / lint-and-test (3.13) (push) Has been cancelled

This commit is contained in:
2026-07-02 22:27:50 +00:00
parent 302d54eb0a
commit 1b51fe65b5
18 changed files with 29 additions and 17 deletions

View File

@@ -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) {