fix(enclave): friendly redirect for invalid/revoked invite code (LC-544) #513
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/LC-544-friendly-invalid-invite-code"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
Joining an enclave with a bad invite code used to dump the user on a raw "400 Bad Request: invalid or revoked code" page, a leftover from early development.
post_join_by_codenow redirects (303) back to/enclaves/discover?error=invalid_invite_code, which renders a friendly, actionable banner through the existingflash_messagemachinery. The discover page is itself the next step: the join form is right there to retry a mistyped code, and the public-enclave list is a way forward.Invalid, revoked, and expired codes all collapse to the same
get_enclave_by_invite_codeNonebranch, so one path covers all three (a revoked or rotated code simply no longer matches any row; a cleared code is NULL and never matches a bound value).Changes
server/src/routes/enclave.rs: on the no-match branch ofpost_join_by_code, returnRedirect::to("/enclaves/discover?error=invalid_invite_code")instead ofAppError::BadRequest. Add theinvalid_invite_codearm toflash_message(plain-string, matching the siblingenclave_name_taken/room_name_takenarms).Testing
just testandjust test-saasboth green;just checkclean (clippy + fmt + desktop compile).New route tests in
server/tests/routes_enclave.rscover all three acceptance-criteria paths: invalid code -> 303 to discover; revoked code (rotate the live code, retry the old one) -> 303 to discover; valid code -> 303 to/enclave/{id}and the joiner reaches the enclave landing as a member. Acreate_enclave_with_codehelper reads the server-generated code back off the settings page. The stalejoin_by_invalid_invite_code_400assertion (which pinned the old raw-400 behavior) is replaced.Notes
Not operator-visible: no env var, config, or API-contract change, so no
[operator-action]marker. The two remaining "invalid or revoked code" string hits are in historicaldocs/superpowers/**build-plan/spec files (immutable build-history; the spec actually recorded the original intent as a "form re-render", which this restores) and are intentionally left untouched.#LC-544