Bugfix: What caused the infinite redirect loop in gograb-admin after...

Documentation for Sessions

🐛 Bugfix: What caused the infinite redirect loop in gograb-admin after...

Date: 2026-03-14
Time: 17:57:24 UTC
Session: gspace1-220.4
Agent: angular
Confidence: 98%
Status: ✅ Documented


📋 Decision Context

Question:

What caused the infinite redirect loop in gograb-admin after adding 'executive' to admin guards?

Task: S220: Fix infinite redirect loop


🎯 Decision Made

Chosen:

Rewrote adminRoleGuard to use AuthService instead of raw localStorage. The guard was reading localStorage('auth_backup') directly while strictAuthGuard used AuthService.isAuthenticated(). When auth_backup was null/malformed, adminRoleGuard silently redirected to /login via catch block, but loginPageGuard saw user as authenticated and redirected to /dashboard → infinite loop.

Options Considered:

  1. Fix localStorage format to match AuthService (fragile — keeps dual source of truth)
  2. Rewrite guard to use AuthService (chosen — eliminates dual source of truth)
  3. Remove adminRoleGuard entirely and rely on strictRoleGuard (would work but loses app-level control)

💭 Reasoning

The bug was NOT that executive was missing (though it was). The root cause was architectural: adminRoleGuard bypassed AuthService and read raw localStorage, creating a dual source of truth. strictAuthGuard said 'yes authenticated' (via AuthService signals) while adminRoleGuard said 'no auth_backup found' (via raw localStorage). This is a systemic problem — when guards use different auth sources, any desync creates loops. The fix uses AuthService.isAuthenticated() and authService.userRole() which are the canonical source of truth, consistent with every other guard. Early warning signals: any guard that imports Router but NOT AuthService is suspect. Any guard that reads localStorage directly is a ticking time bomb.


📁 Files Involved


🔗 Related


Auto-generated by MCP Smart Consolidation