Skip to content

feat(admin): change passwords from Admin UI (#115) - #137

Merged
benders merged 3 commits into
mainfrom
feat/115-admin-password-update
Jul 12, 2026
Merged

feat(admin): change passwords from Admin UI (#115)#137
benders merged 3 commits into
mainfrom
feat/115-admin-password-update

Conversation

@benders

@benders benders commented May 4, 2026

Copy link
Copy Markdown
Owner

Summary

  • Adds PUT /admin/users/:id/password (admin-only, validates length >= 8, allows admin to change own password).
  • Per-row "Change password" form in AdminPage, with confirm field and own-account notice that cached subsonicCredentials go stale until re-login.
  • Updates docs/authentication.md with the new endpoint and the stale-credentials caveat.

Scope per discussion on #115: admin-only UI for now; non-admin self-service deferred until non-admins can log into the SPA.

closes #115

Test plan

  • pnpm typecheck passes.
  • pnpm test passes (335 hub + 53 frontend).
  • Manual: log in as admin, change a guest user's password, verify Subsonic auth (/rest/ping?u=&p=) accepts new and rejects old.
  • Manual: change own admin password, see notice, log out + back in, confirm SPA streaming refreshed.

🤖 Generated with Claude Code

… passwords

Adds an admin-only endpoint to set any user's password (including the
admin's own), plus a per-row "Change password" form in the Admin UI.
Self-update surfaces a notice that cached subsonicCredentials are stale
until re-login.

closes #115

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
The branch predates the admin-namespace split (#226) and the AdminPage
→ features/hub-admin/ decomposition, so beyond the textual merge:

- PUT /users/:id/password now lives in hubAdminRoutes, reachable at
  /api/admin/hub/users/:id/password; the api client, the test URLs,
  and docs/authentication.md updated to the new namespace.
- AdminPage.tsx was deleted on main; the ChangePasswordForm and per-row
  password toggle are ported into features/hub-admin/UsersSection.tsx,
  with currentUserId taken from the auth store instead of the old
  find-the-admin heuristic.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011Q3riZ78G26ohMgPDh8F7u
@benders

benders commented Jul 12, 2026

Copy link
Copy Markdown
Owner Author

FROM @claude:

Brought the branch up to date with current main (46a0fca). The branch predated two big restructurings, so the merge needed more than conflict resolution:

  • Admin namespace split (Admin mount hardening: per-namespace handler partition (follow-up to #212) #226): PUT /users/:id/password landed in hubAdminRoutes, so it's now served at /api/admin/hub/users/:id/password. The api client, the tests, and docs/authentication.md were updated to match.
  • AdminPage decomposition: AdminPage.tsx no longer exists on main — the ChangePasswordForm and per-row key-icon toggle were ported into features/hub-admin/UsersSection.tsx, with currentUserId now read from the auth store.

Verification: pnpm verify green (hub + frontend, admin-routes 47/47 incl. the six password tests), pnpm lint zero output, federation suite green (84/84 py-sonic + eviction + re-admission acts, which are now on main via #250).

…orm (refs #115)

- Backend: a logged-in non-admin guest PUTting /api/admin/hub/users/:id/password
  gets 403 from requireOwner and the target's password_enc is unchanged —
  guards against the route ever losing its preHandler.
- Frontend: new UsersSection.test.tsx covers the change-password form —
  key-icon toggle, mismatch blocks the mutation, updateUserPassword called
  with the row id, stale-credentials notice only on self-update, API error
  rendering. Labels gained htmlFor/id pairing so the inputs are
  accessible-queryable (and correctly associated for real users).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011Q3riZ78G26ohMgPDh8F7u
@benders

benders commented Jul 12, 2026

Copy link
Copy Markdown
Owner Author

FROM @claude:

Added the missing test coverage (dab3b08):

  • Backend: a logged-in non-admin guest calling PUT /api/admin/hub/users/:id/password is refused with 403 and the target's password is verified unchanged — protects the requireOwner guard on this route specifically.
  • Frontend: new UsersSection.test.tsx (6 tests) covering the change-password form: key-icon toggle, confirm-mismatch blocks the call, updateUserPassword invoked with the row's id, stale-credentials notice shown only on self-update, and API-error rendering. The form labels gained htmlFor/id pairing (accessibility fix, also needed for the tests).

Verified: pnpm verify green — hub 750/750, frontend 121/121 — and pnpm lint zero output.

@benders
benders marked this pull request as ready for review July 12, 2026 15:44
@benders
benders merged commit 896a491 into main Jul 12, 2026
2 checks passed
@benders
benders deleted the feat/115-admin-password-update branch July 12, 2026 15:45
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.

Update passwords from admin interface

2 participants