-
Administrator authored
The router beforeEach guard was a 40-line inline function mixing auth state checks, LAN bypass, and route resolution. Pulled the decision logic into src/utils/authGuard.js — a pure function checkAuth(to, authState) → {allowed, reason, redirect?} — that takes the auth store as a plain object and returns a verdict. No Pinia, no vue-router, no DOM imports. Trivially testable (21 spec covering LAN bypass, already-authed-on-login, refresh-failed, etc.). Router guard shrinks to 5 lines; AppLayout drops a redundant router.push('/login') (auth.logout already navigates internally); 5 master-data views drop redundant onMounted initializeAuth() calls (initializeAuth now runs once in main.js at boot). Co-Authored-By:Claude <noreply@anthropic.com>
cb14a136