Added access code regeneration endpoint#27988
Conversation
Trial private sites mark the access code setting as read-only, so the UI cannot use generic settings edits to regenerate it.\n\nAdd an explicit settings endpoint that generates a new code server-side and writes it with internal context. Wire Admin-X to call the endpoint without sending a caller-provided value.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
WalkthroughThis PR introduces a dedicated backend endpoint and frontend hook for regenerating private site access codes. The service method generates a new code and persists it via internal settings context, bypassing the generic settings edit path that may be locked. The API endpoint exposes this with edit permission validation and cache invalidation. The frontend hook mirrors other settings mutations with query caching and invalidation patterns. The component switches from generic settings edits to the new hook, extracting and displaying the regenerated code. Unit, acceptance, and e2e tests verify the behavior across the stack. Possibly related PRs
Suggested labels
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #27988 +/- ##
==========================================
+ Coverage 73.81% 73.83% +0.01%
==========================================
Files 1523 1523
Lines 128935 128982 +47
Branches 15479 15484 +5
==========================================
+ Hits 95177 95236 +59
+ Misses 32799 32785 -14
- Partials 959 961 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Changed `/settings/regenerate_access_code` to `/settings/access_code/regenerate` to follow the existing API pattern where routes are structured as noun/verb (e.g. `posts/:id/copy`, `themes/:name/activate`). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Context
Trial private sites mark the private-site access code setting as read-only, so the Access settings UI cannot regenerate it through the generic settings edit path without getting blocked.
Summary
POST /settings/regenerate_access_codeaction that generates a new private-site access code server-side.Testing
source ~/.nvm/nvm.sh && nvm use 22 && pnpm test:single test/unit/server/services/settings/settings-service.test.jssource ~/.nvm/nvm.sh && nvm use 22 && pnpm test:single test/e2e-api/admin/settings.test.jssource ~/.nvm/nvm.sh && nvm use 22 && pnpm --filter @tryghost/admin-x-settings test:acceptance -- membership/access.test.tsNotes