fix(sw): bump SW version to 41; fix page guard fallback to avoid loops
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-03 08:27:11 +00:00
parent 0bd5ee8ee8
commit 07dad0801e
2 changed files with 31 additions and 4 deletions

View File

@@ -223,9 +223,36 @@
function enforcePageGuard(userRole, userPerms) {
if (isPageAllowed(path, userRole, userPerms)) return true;
var fallback = '/pos/catalog';
if (userRole === 'counter' || userRole === 'cashier') fallback = '/pos/sale';
else if (userRole === 'workshop' || userRole === 'mechanic') fallback = '/pos/workshop';
// Build the actual list of allowed pages so we can pick a safe fallback.
var fallback = null;
if (userRole === 'owner' || userRole === 'admin') {
fallback = '/pos/dashboard';
} else if (['workshop', 'mechanic', 'counter', 'cashier'].indexOf(userRole) !== -1) {
var allowed = [];
if (userRole === 'workshop' || userRole === 'mechanic') allowed = ['/pos/workshop'];
var permMap = {
'pos.sell': '/pos/sale',
'pos.view': '/pos/sale',
'catalog.view': '/pos/catalog',
'inventory.view': '/pos/inventory',
'customers.view': '/pos/customers',
'workshop.view': '/pos/workshop',
'pos.remission': '/pos/remission-notes',
'invoicing.view': '/pos/invoicing',
'quotations.view': '/pos/quotations',
'accounting.view': '/pos/accounting',
'reports.view': '/pos/reports',
'dashboard.view': '/pos/dashboard'
};
for (var p in permMap) {
if (userPerms.indexOf(p) !== -1 && allowed.indexOf(permMap[p]) === -1) {
allowed.push(permMap[p]);
}
}
fallback = allowed.length ? allowed[0] : '/pos/login';
} else {
fallback = '/pos/dashboard';
}
window.location.replace(fallback);
return false;
}

View File

@@ -6,7 +6,7 @@
// The fetch handler normalizes static asset URLs (strips ?v= query strings)
// so templates can use cache-busting query params freely.
const VERSION = 40;
const VERSION = 41;
const CACHE_NAME = 'nexus-pos-v' + VERSION;
const APP_SHELL = [