Skip to content
This repository was archived by the owner on Jul 6, 2026. It is now read-only.

fix(web): admin role not recognized (PascalCase) — normalize in AdminGuard#86

Merged
Enes1998 merged 1 commit into
mainfrom
fix/admin-role-normalize
Jun 7, 2026
Merged

fix(web): admin role not recognized (PascalCase) — normalize in AdminGuard#86
Enes1998 merged 1 commit into
mainfrom
fix/admin-role-normalize

Conversation

@Enes1998

@Enes1998 Enes1998 commented Jun 7, 2026

Copy link
Copy Markdown
Collaborator

enes.admin@loopless.dev (Role=Admin in DB + KC) was shown "Admin access required" on the admin host.

Root cause: the API returns user.role as PascalCase "Admin", but AdminGuard.isAdmin() checked role === "admin" || role === 2 → false. Same casing class as the earlier AppNavigation fix.

Fix: route the AdminGuard check (and the getting-started checklist's enterprise check, same raw pattern on user.role) through normalizeRole().

Verified: tsc ✓, next lint 0 warnings ✓. Frontend-only.

The API serializes the user role as PascalCase ("Admin"/"Enterprise"/"Freelancer").
AdminGuard checked `role === "admin" || role === 2`, so a real admin was shown the
"Admin access required" screen. Route both raw role comparisons through normalizeRole
(case/format-insensitive), matching the rest of the app.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@Enes1998 Enes1998 merged commit 078953c into main Jun 7, 2026
6 checks passed
@Enes1998 Enes1998 deleted the fix/admin-role-normalize branch June 13, 2026 16:28
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant