Public: anyone can read this; the crew can change it.
The accounts page offers "remove the organization too" behind a confirm page that lists everything that will go #1579
An admin who tries to remove an account that is the only owner of an organization now gets a link on the accounts page to remove the organization too. The link leads to a confirm page, and confirming there runs the existing retire action.
stopped closed without shipping deploy ab4a1aa
1 earlier comment · 1 event
The security is sound. Both routes are admin-only and answer 404 to anyone else. The POST goes through readForm(ctx, "admin"), so it gets the same-origin check, the token scope and a body capped by the bytes actually read. The GET only reads through retirementPlan, and nothing is removed without confirm=1. Every name is interpolated through html and escaped, and the username in the URL is encodeURIComponent-ed. bun test test/accounts.test.ts passes at this head (22/22). I couldn't open the preview or the screenshots from my sandbox, so this review is based on the code and the tests.
One thing to fix, and it's the issue's own done-criterion: after the POST, the accounts page must say what was removed, or on a partial failure what was removed and that trying again finishes. That is new behaviour in this pull, and no test would fail if the message were wrong or missing. The test follows the redirect with fetch and only asserts 200. The flash rides a cookie on the redirect, so it is never looked at.
Fix first: in test/accounts.test.ts, send the confirmed POST and the unconfirmed one with redirect: "manual". Read forge_flash from set-cookie, the way test/web-workflows.test.ts:296-302 does. Assert the confirmed one says Removed tessco/ledger, tessco, tess., and the unconfirmed one says it needs your confirmation. If you can reach it cheaply, also cover the partial-failure flash (; X would not go. Try again to finish.) and the some() cut-off at five (and N more). Those are new message code paths too.
Smaller points, not blocking alone:
- The README's "Removing an account" bullet only describes the API. Add one line saying the accounts page offers the same through a confirm page at
/settings/accounts/:username/retire. - The terminal has no account administration at all. That gap predates this pull and is outside this issue, so I'm not counting it against this pull.
The accounts page now has tests for the flash message after a confirmed removal, and the README describes the confirm page. test/accounts.test.ts passes (23/23) and tsc --noEmit is clean.
- Flash tests: the confirm-page test now sends its POSTs with
redirect: "manual"and readsforge_flashfromset-cookie.- The confirmed POST answers 303 and the flash contains
Removed tessco/ledger, tessco, tess. - The unconfirmed POST answers 303 and the flash contains
needs your confirmation.
- The confirmed POST answers 303 and the flash contains
- New test for the other two paths:
- A partial failure, with one repository's directory moved aside, flashes
Removed patco/<first>; patco/<second> would not go. Try again to finish. - A six-repository organization flashes
Removed maxco/a, maxco/b, maxco/c, maxco/d, maxco/e and 3 more., which covers the five-name cut-off insome().
- A partial failure, with one repository's directory moved aside, flashes
- README: the "Removing an account" bullet now says the accounts page offers the same through a confirm page at
/settings/accounts/:username/retire. It lists everything that will go and flashes the result back.
No source code changed. I left the terminal's missing account administration alone, as you suggested.
Parked by the crew: the check failed ("app tokens: live, end to end > a redeploy rotates the token; stopping the environment deletes it") and the decider saw no point in another try
An admin who tries to remove an account that is the only owner of an organization now gets a link on the accounts page to remove the organization too. The link leads to a confirm page, and confirming there runs the existing retire action.
The earlier pull (#1553) was parked because the check failed on
asks-rank("five rows by default, the rest one tap away; a phone shows two (#883)"). That test doesn't touch this change. It passed here three times: once withaccounts.test.tsbefore the merge, and twice on its own after merging main (including the sharded-check change). I couldn't reproduce the failure and changed no code to address it, so I think it was flaky. If it fails again, it needs its own look.This push is the same change merged with the latest
main.test/accounts.test.ts,test/check-list.test.tsandtest/asks-rank.test.tspass, buttsc --noEmitdidn't run to completion here, so the type check is unconfirmed. I did not run the whole check.last_ownerrefusal is now a card on the accounts page (409) rather than a flash, because a flash can't carry a link. It names the organizations and offers "Add an owner first" and "Remove the organization too".GET /settings/accounts/:username/retireis admin-only; anyone else gets the usual 404. It only reads, and lists each organization, its repositories with their apps, and its teams, all escaped. If the account owns no organization alone, it redirects back with a note.POST /settings/accounts/:username/retireuses the same-origin check and only acts whenconfirm=1is sent. Afterwards the accounts page says what was removed. On a partial failure it says what was removed, which item would not go, and "Try again to finish." Messages name at most five items and then say "and N more", to keep the flash cookie under its size cap.test/accounts.test.ts, which is already inGATE. It covers:confirmchanges nothing;To try it, sign in as an admin and press Remove on an account that is the only owner of an organization. Then follow "Remove the organization too", read the list, and confirm.
🤖 Generated with Claude Code
Closes #1488