Let users change their own password in the gateway - #323
Open
abeldantas wants to merge 4 commits into
Open
Conversation
A dashboard user who knows their current password can now set a new one without involving an admin. This is the first slice of f17 (self-service password management); admin-initiated resets are out of scope here. Backend: PUT /auth/me/password — verifies the current password, hashes the replacement, and commits. Rejects OIDC-only accounts (no hash to verify against) with 403. Frontend: ChangePasswordDialog accessible from the NavRail account menu, following the existing CreateUserDialog pattern (MUI Dialog, inline error/success alerts, confirm-password guard).
The change-password endpoint accepted any string, including empty — a curl call could set an account's password to "" and leave it unrecoverable from the login form. Add min_length=8 on ChangePasswordRequest.new_password so Pydantic rejects degenerate values before the handler runs. Also adds the missing test coverage: happy path, wrong current password → 403, short password → 422, empty password → 422.
5 tasks
There was a problem hiding this comment.
Pull request overview
Adds self-service password change support to the Switch Gateway, wiring a new authenticated backend route through the frontend UI and covering the behavior with unit tests.
Changes:
- Adds a Gateway UI “Change password” dialog and a NavRail menu entry to open it.
- Introduces a frontend API helper to call the password change endpoint.
- Implements
PUT /auth/me/passwordin the gateway backend with a request schema and tests.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| gateway/src/layout/NavRail.tsx | Adds a “Change password” menu item and mounts the dialog. |
| gateway/src/layout/ChangePasswordDialog.tsx | New dialog UI for submitting current/new password and surfacing success/error. |
| gateway/src/data/api.ts | Adds changePassword() client wrapper calling the backend route. |
| core/tests/switch_core/gateway/test_change_password.py | Adds route-level tests for success and validation/error cases. |
| core/switch_core/gateway/schemas.py | Adds ChangePasswordRequest schema with min-length validation. |
| core/switch_core/gateway/auth_routes.py | Implements PUT /auth/me/password and updates the user password hash. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Guard handleClose so it's a no-op during an in-flight request, preventing stale success/error state on next open.
Add autoComplete attributes (current-password / new-password) to the TextFields so password managers integrate correctly. Add a test for the OIDC user case (password_hash=None → clean 403).
amaudruz
requested changes
Sep 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
PUT /auth/me/passwordendpoint that lets authenticated users change their own password by providing current + new password.Test plan
pytest tests/switch_core/gateway/test_change_password.py— 5 tests pass.