fix(auth): redirige a taller y limpia SW para usuarios workshop/mechanic
- Agrega script inline en todas las plantillas (excepto login/workshop) que lee el rol del JWT y redirige a /pos/workshop si es workshop/mechanic. - Desregistra el Service Worker antes de redirigir para forzar carga fresca de assets y evitar que menus antiguos permanezcan por cache. - Actualiza labels de rol en auth_bp.py para taller y mecanico. Tests: 35 passed
This commit is contained in:
@@ -16,6 +16,18 @@
|
||||
<link rel="shortcut icon" type="image/png" href="/pos/static/pwa/icon-192.png" />
|
||||
|
||||
<link rel="stylesheet" href="/pos/static/css/invoicing.css">
|
||||
<script id="workshop-mechanic-redirect">
|
||||
(function(){
|
||||
var t=localStorage.getItem("pos_token");
|
||||
if(!t)return;
|
||||
try{var p=JSON.parse(atob(t.split(".")[1]));var r=(p.role||"").toLowerCase();
|
||||
if((r==="workshop"||r==="mechanic")&&window.location.pathname!=="/pos/workshop"){
|
||||
if("serviceWorker" in navigator){navigator.serviceWorker.getRegistrations().then(function(rs){rs.forEach(function(reg){reg.unregister();});});}
|
||||
window.location.replace("/pos/workshop");
|
||||
}
|
||||
}catch(e){}
|
||||
})();
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
Reference in New Issue
Block a user