Add optional display username for dashboard users - #210
Merged
Conversation
Adds a nullable, case-insensitively-unique username column and threads it through UserView on signup verification, login, refresh, and /me. Adds PATCH /v1/auth/me to set it (3-20 chars, alphanumeric/underscore/ hyphen, 400 on duplicate). Backs the frontend's dashboard greeting and Settings page.
migrate_applies_exactly_the_expected_version_set hardcoded the known migration versions; it needed the new username migration added to its expected list.
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.
Why
The dashboard greeting currently falls back to the email address for a display name (e.g. showing the raw local-part of an email like `lateeftosin1999`), which reads as an account handle rather than a name. There was no way for a user to set an actual display name, and no field to carry one.
What changed
Where
Solution
Kept the write path minimal and separate from account creation: username stays `null` until a user explicitly sets one via the new `PATCH` endpoint, so existing accounts are unaffected. Uniqueness is enforced at the database level (case-insensitive unique index) rather than only in application code, so it holds even under concurrent requests. Verified locally against a real Postgres instance: migration applies cleanly, `fmt`/`clippy`/`cargo test --workspace` all pass, and the endpoint was exercised end-to-end (set username, fetch it back, and confirm a case-insensitive duplicate is rejected).
This is a companion to the Octo-frontend PR that adds the dashboard UI (greeting + Settings page) consuming this endpoint.