[Medium] domain-detail route has no auth guard but API requires Authorize #64

Closed
opened 2026-05-05 04:15:55 +00:00 by spikerj · 1 comment
Owner

Severity: Medium (UX)

Files:

  • spikersoft-angular/projects/spikersoft/src/routes.ts (domain-detail route)
  • spikersoft-angular/projects/spikersoft/src/app/_components/learning/domain-detail/domain-detail.component.ts (~86-91)

Problem: Route has canActivate: [] (anonymous accessible) but the API endpoint requires [Authorize]. Anonymous users get a vague failed-load. The component's catch { } block also hides 401 vs 404 vs network errors.

Fix:

  • Add an AuthGuard (or matching pattern used elsewhere) on the route
  • Differentiate error types in the component's catch block: show login prompt for 401, not-found for 404, generic network error otherwise

Acceptance criteria:

  • Anonymous users see login prompt, not silent failure
  • Authenticated users get full functionality
  • Error states are distinguishable in UI
**Severity:** Medium (UX) **Files:** - `spikersoft-angular/projects/spikersoft/src/routes.ts` (domain-detail route) - `spikersoft-angular/projects/spikersoft/src/app/_components/learning/domain-detail/domain-detail.component.ts` (~86-91) **Problem:** Route has `canActivate: []` (anonymous accessible) but the API endpoint requires `[Authorize]`. Anonymous users get a vague failed-load. The component's `catch { }` block also hides 401 vs 404 vs network errors. **Fix:** - Add an `AuthGuard` (or matching pattern used elsewhere) on the route - Differentiate error types in the component's catch block: show login prompt for 401, not-found for 404, generic network error otherwise **Acceptance criteria:** - [ ] Anonymous users see login prompt, not silent failure - [ ] Authenticated users get full functionality - [ ] Error states are distinguishable in UI
Author
Owner

Resolved.

Applied two changes:

  1. routes.ts -- the tree-of-knowledge/domain/:domainKey route now uses canActivate: [AuthGuard] to match the [Authorize] API endpoint.
  2. domain-detail.component.ts -- replaced the silent catch {} with describeLoadError(err: unknown) which differentiates HttpErrorResponse statuses 0 (network), 401 (sign in), 403 (unauthorized), 404 (not found), and other (Failed to load domain detail (NNN)).

Files changed:

  • spikersoft-angular/projects/spikersoft/src/routes.ts
  • spikersoft-angular/projects/spikersoft/src/app/_components/learning/domain-detail/domain-detail.component.ts
**Resolved.** Applied two changes: 1. `routes.ts` -- the `tree-of-knowledge/domain/:domainKey` route now uses `canActivate: [AuthGuard]` to match the `[Authorize]` API endpoint. 2. `domain-detail.component.ts` -- replaced the silent `catch {}` with `describeLoadError(err: unknown)` which differentiates `HttpErrorResponse` statuses 0 (network), 401 (sign in), 403 (unauthorized), 404 (not found), and other (`Failed to load domain detail (NNN)`). Files changed: - `spikersoft-angular/projects/spikersoft/src/routes.ts` - `spikersoft-angular/projects/spikersoft/src/app/_components/learning/domain-detail/domain-detail.component.ts`
Sign in to join this conversation.