fix(auth): restringe workshop/mecanico solo por servidor y cookie
Some checks failed
CI / lint-and-test (3.11) (push) Has been cancelled
CI / lint-and-test (3.13) (push) Has been cancelled

- Elimina el script inline que redirigia a todos los usuarios.
- auth_bp.py: la respuesta de login ahora setea cookie pos_role.
- app.py: before_request redirige a /pos/workshop solo cuando la cookie
  indica rol workshop/mechanic (no depende de JS cacheado).
- login.js/login.min.js/app-init.js: sincronizan/limpian la cookie pos_role
  junto con el token en login y logout.

Tests: 35 passed
This commit is contained in:
2026-06-30 16:57:11 +00:00
parent 688ea8c70c
commit a37e60eb2a
22 changed files with 42 additions and 243 deletions

View File

@@ -34,20 +34,7 @@
.pagination button:disabled { opacity: 0.5; cursor: not-allowed; }
.pagination span { font-size: 13px; color: #4b5563; }
.loading { text-align: center; padding: 40px; color: #6b7280; }
</style>
<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>
</style></head>
<body>
<div class="header">
<h1>📊 Ventas Históricas - Atlas</h1>