feat: add ability to edit API token scopes #699

Merged
jmiller merged 2 commits from feature/edit-token-scopes into main 2026-06-25 15:00:25 +00:00
Owner

Summary

  • Add PATCH /users/{username}/tokens/{id} API endpoint to edit token name and scopes
  • Add edit button + modal in web UI (User Settings > Applications)
  • Modal pre-populates with current token scopes for easy modification
  • Model layer UpdateAccessToken() already existed — this exposes it through API and UI

Closes #697 (partially — licensing scope was PR #698, this adds editability)

Changes

  • modules/structs/user_app.go: New EditAccessTokenOption struct
  • routers/api/v1/user/app.go: New UpdateAccessToken() handler with swagger docs
  • routers/api/v1/api.go: PATCH route on /tokens/{id}
  • routers/web/user/setting/applications.go: New EditApplication() handler
  • routers/web/web.go: POST /edit route
  • templates/user/settings/applications.tmpl: Edit button + scope modal with JS
  • options/locale/locale_en-US.json: New locale strings

Test plan

  • API: PATCH token with new scopes returns 200 with updated scopes
  • API: PATCH token with invalid scope returns 400
  • API: PATCH token with empty scopes returns 400
  • API: PATCH nonexistent token returns 404
  • API: PATCH another user's token returns 404 (ownership check)
  • Web UI: Edit button appears next to each token
  • Web UI: Modal opens with current scopes pre-selected
  • Web UI: Saving updates scopes and shows success flash
  • Existing all scoped tokens are unaffected
## Summary - Add PATCH `/users/{username}/tokens/{id}` API endpoint to edit token name and scopes - Add edit button + modal in web UI (User Settings > Applications) - Modal pre-populates with current token scopes for easy modification - Model layer `UpdateAccessToken()` already existed — this exposes it through API and UI Closes #697 (partially — licensing scope was PR #698, this adds editability) ## Changes - `modules/structs/user_app.go`: New `EditAccessTokenOption` struct - `routers/api/v1/user/app.go`: New `UpdateAccessToken()` handler with swagger docs - `routers/api/v1/api.go`: PATCH route on `/tokens/{id}` - `routers/web/user/setting/applications.go`: New `EditApplication()` handler - `routers/web/web.go`: POST `/edit` route - `templates/user/settings/applications.tmpl`: Edit button + scope modal with JS - `options/locale/locale_en-US.json`: New locale strings ## Test plan - [ ] API: PATCH token with new scopes returns 200 with updated scopes - [ ] API: PATCH token with invalid scope returns 400 - [ ] API: PATCH token with empty scopes returns 400 - [ ] API: PATCH nonexistent token returns 404 - [ ] API: PATCH another user's token returns 404 (ownership check) - [ ] Web UI: Edit button appears next to each token - [ ] Web UI: Modal opens with current scopes pre-selected - [ ] Web UI: Saving updates scopes and shows success flash - [ ] Existing `all` scoped tokens are unaffected
jmiller added 2 commits 2026-06-25 14:59:00 +00:00
Add PATCH /users/{username}/tokens/{id} API endpoint and web UI edit
button so token scopes can be modified after creation without having
to delete and recreate the token.
fix: reject empty token update requests with 400
Universal: PR Check / Branch Policy (pull_request) Failing after 3s
Generic: Repo Health / Site Health (pull_request) Has been skipped
Generic: Repo Health / Access control (pull_request) Successful in 2s
Universal: PR Check / Validate PR (pull_request) Failing after 11s
Universal: Auto Version Bump / Version Bump (push) Successful in 17s
PR RC Release / Build RC Release (pull_request) Failing after 1m5s
Universal: PR Check / Secret Scan (pull_request) Successful in 1m7s
Branch Cleanup / Delete merged branch (pull_request) Successful in 1s
RC Revert / Rename rc/ back to dev/ (pull_request) Has been skipped
Universal: Build & Release / Promote to RC (pull_request) Has been skipped
Universal: Build & Release / Build & Release Pipeline (pull_request) Failing after 57s
Universal: Workflow Sync Trigger / Sync workflows to live repos (pull_request) Failing after 3m52s
Universal: PR Check / Build RC Package (pull_request) Has been cancelled
Universal: PR Check / Report Issues (pull_request) Has been cancelled
Generic: Repo Health / Scripts governance (pull_request) Has been cancelled
Generic: Repo Health / Repository health (pull_request) Has been cancelled
Generic: Repo Health / Report Issues (pull_request) Has been cancelled
f7c2b205c5
jmiller force-pushed feature/edit-token-scopes from 9a418d40f5 to f7c2b205c5 2026-06-25 14:59:00 +00:00 Compare
jmiller merged commit 2708388542 into main 2026-06-25 15:00:25 +00:00
jmiller deleted branch feature/edit-token-scopes 2026-06-25 15:00:26 +00:00
Sign in to join this conversation.