Skip to content

feat: allow password changes through PUT /api/v1/admin/users/{id} - #102

Open
aaronbrethorst wants to merge 8 commits into
feed-trip-descriptor-androidfrom
admin-api-user-password
Open

feat: allow password changes through PUT /api/v1/admin/users/{id}#102
aaronbrethorst wants to merge 8 commits into
feed-trip-descriptor-androidfrom
admin-api-user-password

Conversation

@aaronbrethorst

Copy link
Copy Markdown
Member

Summary

Third PR in the stack. The admin web UI's edit-user form can already reset a password, but the JSON API could not, and user_store.go carried a stale TODO saying a separate endpoint was needed. This brings PUT /api/v1/admin/users/{id} to parity with the UI:

  • password is an optional field on the update body. Blank (or absent) keeps the current password.
  • A non-blank password is validated (8+ characters) before any write; a short one returns 400 password must be at least 8 characters and neither the profile nor the hash is touched.
  • On success the profile is updated, then the password hash, using the existing bcrypt UpdateUserPassword store method. The password never appears in the response.
  • The stale TODO is gone.
  • README notes that a password change, like deactivation, does not revoke tokens already issued (they live up to 24 h).

Additive: existing clients sending only name/email/role are unaffected; unknown fields are still rejected.

Test plan

  • go vet ./... && go test ./...
  • New TestHandleUpdateUser_PasswordOptional: blank leaves the hash alone; new password applied after the profile update and not echoed; short password rejected before any write
  • TestHandleUpdateUser_UnknownFieldRejected updated to use a genuinely unknown field (it previously used password as its example)

@coderabbitai

coderabbitai Bot commented Sep 7, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Team

Run ID: ed45c68d-fee4-4c16-a5c5-b34e22b8dc79

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

docs: production deployment guide and operator manual; fix the Docker build
diveshpatil9104 added a commit to diveshpatil9104/vehicle-positions that referenced this pull request Sep 8, 2026
The guard read one hardcoded path, docs/configuration.md, so it only worked
while the reference lived in the file this branch adds. That couples a test
about whether a variable is documented to a question it should not care about:
which file documents it.

OneBusAway#102 adds a configuration reference inside docs/deployment.md covering the same
27 variables. Whichever of the two files ends up canonical, every variable the
server reads should still have to appear in one of them, and a hardcoded path
would fail for the wrong reason the moment that choice changes.

documentedVariables now scans README.md and docs/*.md, skipping
docs/superpowers -- those are design specs and implementation plans, so a
variable named in a table there is not documented for the person deploying
this. It returns the file each variable was found in, so a stale-row failure
names the file to edit rather than a path the reader has to go looking for.

Verified both directions: moving the table to docs/deployment.md keeps the
suite green, and removing it entirely turns it red.
diveshpatil9104 added a commit to diveshpatil9104/vehicle-positions that referenced this pull request Sep 8, 2026
Scan README.md and docs/*.md instead of one hardcoded path, so the guard holds
whether the table stays here or moves into OneBusAway#102's docs/deployment.md.
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.

1 participant