Skip to content

Fix User Management page showing no users in any tab - #163

Merged
kristofer merged 2 commits into
mainfrom
copilot/fix-users-page-visibility-again
Jun 10, 2026
Merged

kristofer merged 2 commits into
mainfrom
copilot/fix-users-page-visibility-again

Conversation

Copilot AI commented Jun 10, 2026 •

Copy link
Copy Markdown

The Admin User Management page displayed empty tables across all three tabs (Admins, Active Students, Inactive Students) even when users existed in the database.

Root causes

  • database/user.go — ListUsers() used var users []*models.User (nil slice), which json.Encode serializes as null. The JS client then called .length on null or silently iterated zero times, leaving tables empty.

    // Before: nil → JSON null
    var users []*models.User
    
    // After: always a JSON array []
    users := make([]*models.User, 0)
  • static/js/admin/users.js — No guard against a non-array API response; any unexpected value caused silent failure.

    const rawUsers = await API.get('/admin/users');
    const users = Array.isArray(rawUsers) ? rawUsers : [];
  • static/sw.js — Service worker stale-while-revalidate could serve old cached JS to returning users. Bumped CACHE_NAME from athena-v9 → athena-v10 to evict stale files on next load.

  • api/auth.go — RegisterHandler bypassed h.db.CreateUser() with a raw SQL INSERT that omitted the category column. Refactored to use the interface method, which includes all columns and sets category: "java" explicitly (matching the existing DB default; admins can update it via the User Management page).

Copilot AI linked an issue Jun 10, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Fix user visibility on Users management page Fix User Management page showing no users in any tab Jun 10, 2026
Copilot AI requested a review from kristofer June 10, 2026 13:59
@kristofer
kristofer marked this pull request as ready for review June 10, 2026 14:10
@kristofer
kristofer merged commit 92d8bb4 into main Jun 10, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Well, not quite....

2 participants