feat(templates): display username with full name across admin views#232
Merged
Conversation
Render AuthGate users as "username (full_name)" — falling back to just "username" when full_name is empty — via a shared UserDisplay helper. - Add UserDisplay(username, fullName) helper in templates/props.go - Apply it to the authorizations, connections, and password-reset title sentences, the admin tokens (User) and clients (Creator) table columns, the OAuth consent "Signed in as" tag, and refactor the existing inline two-span logic in admin_client_authorizations to use it - Carry the owner's full name to three low-risk display sites with zero schema changes and zero extra queries: TokenWithUser.FullName and ClientWithCreator.CreatorFullName are filled from the already-fetched GetUsersByIDs map; AuthorizePageProps.FullName from the already-loaded user in ShowAuthorizePage - Add table-driven unit tests for UserDisplay Navbar DisplayName(), the user list/detail/created/form pages, third-party provider identity fields, and the audit/dashboard ActorUsername snapshot columns are intentionally left unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR standardizes how users are displayed across the admin + consent UI by rendering them as username (full_name) when a full name is present, otherwise just username, via a shared templates.UserDisplay helper.
Changes:
- Added
UserDisplay(username, fullName string)helper and extendedAuthorizePagePropswithFullName. - Updated multiple admin and consent templates to use
UserDisplayconsistently (tokens, clients, authorizations, connections, password reset, authorize page). - Enriched backend view-model structs (
TokenWithUser,ClientWithCreator) and authorize page props to carry full name from already-loaded user records (no new queries).
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| internal/templates/props.go | Adds UserDisplay helper and AuthorizePageProps.FullName for consent UI rendering. |
| internal/templates/props_test.go | Adds unit tests covering UserDisplay formatting and empty-full-name fallback. |
| internal/templates/authorize.templ | Shows “Signed in as …” using UserDisplay(props.Username, props.FullName). |
| internal/templates/admin_user_password_reset.templ | Uses UserDisplay in the success message for the target user. |
| internal/templates/admin_user_connections.templ | Uses UserDisplay when describing the linked external identities target user. |
| internal/templates/admin_user_authorizations.templ | Uses UserDisplay in the “Applications that … has granted access to” line. |
| internal/templates/admin_tokens.templ | Uses UserDisplay(tok.Username, tok.FullName) in the User column. |
| internal/templates/admin_clients.templ | Uses UserDisplay(client.CreatorUsername, client.CreatorFullName) in the Creator column (preserving Unknown guard). |
| internal/templates/admin_client_authorizations.templ | Refactors inline conditional full-name rendering to the shared UserDisplay helper. |
| internal/services/token_query.go | Adds TokenWithUser.FullName and populates it from GetUsersByIDs map. |
| internal/services/client.go | Adds ClientWithCreator.CreatorFullName and populates it from GetUsersByIDs map. |
| internal/handlers/authorization.go | Passes user.FullName into AuthorizePageProps for consent rendering. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Address Copilot review: the doc comment predated the FullName field added for "username (full name)" display. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Address Copilot review: assert CreatorFullName is populated from the user lookup, stays empty when the creator has no full name, has no creator, or was deleted. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…richment Address Copilot review: - Revert admin_client_authorizations to the two-span username/full-name rendering so the full name keeps its secondary color and weight, fixing the styling regression introduced by switching to UserDisplay there - Add a focused ListAllTokensPaginated test asserting Username/FullName enrichment for a named user, a user without a full name, and a missing (deleted) owner Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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
Render AuthGate users as
username (full_name)across the admin/consent UI — falling back to justusernamewhen the full name is empty — via a single sharedUserDisplayhelper. Previously these surfaces showed only the username, so admins couldn't tell two similarly-named accounts apart at a glance.What changed
templates/props.go— new package-levelUserDisplay(username, fullName string) string: returns"username (full_name)"whenfullNameis non-empty, elseusername. AddedFullNametoAuthorizePageProps.admin_user_authorizations,admin_user_connections,admin_user_password_reset, and refactored the pre-existing inline two-span logic inadmin_client_authorizationsto use it.TokenWithUser.FullNameandClientWithCreator.CreatorFullNameare populated from the already-fetchedGetUsersByIDsmap intoken_query.go/client.go;ShowAuthorizePagepassesuser.FullNamefrom its already-loaded user. Templatesadmin_tokens(User column),admin_clients(Creator column, keeps the existing!= ""guard → "Unknown"), andauthorize("Signed in as") render via the helper.Intentionally not touched: navbar
DisplayName()(different format — full-name-or-username), the user list/detail/created/form pages (already have a dedicated Full Name column/field), third-partyProviderUsername/ProviderEmail, and theaudit/dashboardActorUsernamesnapshot columns (denormalized, noActorFullName).AI Authorship
plan.md, then refined by an automated 4-agent/simplifyreview pass (reuse / simplification / efficiency / altitude — concluded the diff was already clean).Change classification
Plan reference
Goal (from
plan.md): change "display AuthGate username" sites ininternal/templates/from username-only tousername (full_name), omitting the(xxx)entirely whenfull_nameis empty. Scope explicitly limited to the helper, three pure-template sites, and three low-risk backend sites with no schema/migration/query changes.Verification
UserDisplay:("admin","Administrator")→"admin (Administrator)",("admin","")→"admin",("u1","Wang Xiaoming")→"u1 (Wang Xiaoming)".make generate,make build,make test(templates/services/handlers),make fmt,make lint(0 issues) all pass locally../bin/authgate server; with a user that has a Full Name, open/admin/users/:id/authorizations→ title readsApplications that admin (Administrator) has granted access to; with a user that has no Full Name →Applications that someuser has granted access to(no empty parens). Spot-check/admin/tokens,/admin/clients,/oauth/authorize. Confirm no regression on navbar,/admin/userslist, and/admin/auditactor column.Verifiability check
Risk & rollback
make generateso the UI doesn't reflect.templedits. Both were guarded against — see the "not touched" list and the build steps above.git revertthe commit and re-runmake generate; no DB migration to undo.Reviewer guide
internal/templates/props.go(UserDisplaycontract + the newAuthorizePageProps.FullName); the two enrichment loops ininternal/services/token_query.goandinternal/services/client.go(confirm the field is filled from the existinguserMap, not a new query)..templcall sites — each is a one-line swap toUserDisplay(...);admin_clientskeeps its!= ""→ "Unknown" guard.🤖 Generated with Claude Code