Bugfix: Why was the admin app stuck at /unauthorized after login?

Documentation for Sessions

🐛 Bugfix: Why was the admin app stuck at /unauthorized after login?

Date: 2026-02-11
Time: 12:32:40 UTC
Session: gspace1-105.7
Agent: angular
Confidence: 98%
Status: ✅ Documented


📋 Decision Context

Question:

Why was the admin app stuck at /unauthorized after login?

Task: Session 105: Fix admin app stuck at /unauthorized after login


🎯 Decision Made

Chosen:

Two different AuthService instances. Login flow uses @auth-ui AuthService. The adminRoleGuard and shell used @libs-core/security AuthService which was never updated during login. Fixed by: (1) rewriting adminRoleGuard to read from @auth-ui's Flash Persistence localStorage backup, (2) switching admin shell to @auth-ui AuthService, (3) switching dashboard to @auth-ui AuthService.

Options Considered:

  1. Use @auth-ui AuthService everywhere (chosen)
  2. Sync @libs-core/security from @auth-ui state
  3. Create a unified AuthService

💭 Reasoning

The codebase has two AuthService implementations: @auth-ui (Flash Persistence, signals, used by login/guards) and @libs-core/security (legacy, separate state). When a user logged in via @auth-ui's LoginComponent, only @auth-ui's AuthService was updated. The adminRoleGuard imported from @libs-core/security, called getCurrentUser() which returned null, and redirected to /unauthorized. The strictAuthGuard (from @auth-ui) passed because it checked the correct service. This created an impossible state: authenticated according to @auth-ui but unrecognized by @libs-core/security. The fix ensures all admin app auth operations use the same AuthService (@auth-ui) that handles the login flow.


📁 Files Involved


🔗 Related


Auto-generated by MCP Smart Consolidation