Repository navigation
fix(platform-objects): Setup create_user / set_user_password offer one password rule — generatePassword is a constant, not a ticked box - #22838
Conversation
…assword as a constant, not a ticked box
The password field's own label ("leave empty to generate") is the one rule
the admin reads. generatePassword leaves both dialogs' params and rides in
bodyExtra as a constant true, so the endpoint's explicit-wins rule gives the
label's behaviour: a typed password wins, an empty one generates. The
endpoint's contract for other callers is unchanged.
Claude-Session: https://claude.ai/code/session_013LbZ9MhPp1iriZEtgJqioA
Co-authored-by: Claude <noreply@anthropic.com>
…he endpoint The declared create_user / set_user_password actions are composed into the body the console sends (collected params, recordIdParam, bodyExtra last) and driven through the real endpoints: a typed password wins, an empty or absent one generates. set-user-password gains the explicit-wins, empty-generates and neither-is-400 control rows create-user already had; the create-user control asserts the envelope code too. Claude-Session: https://claude.ai/code/session_013LbZ9MhPp1iriZEtgJqioA Co-authored-by: Claude <noreply@anthropic.com>
…sword leaves both dialogs Regenerated with `node scripts/check-i18n-bundles.mjs --write`; only the two generatePassword param labels leave the four objects bundles. Claude-Session: https://claude.ai/code/session_013LbZ9MhPp1iriZEtgJqioA Co-authored-by: Claude <noreply@anthropic.com>
📓 Docs Drift CheckThis PR changes 1 package(s): 1 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
⛔ 1 release-owned page(s) also name something this change touched. These are read-only:
What this run could not see
Coarse fallback — 3 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 35ac418935cfd5f937f2b6d3cba9299d3d18c900 && git checkout 35ac418935cfd5f937f2b6d3cba9299d3d18c900
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin efcbac73cc58510278b970949ac3b65cb9712815 a73ff6a0e5174bd12c7e7e8fa626e1f304c84998 && git checkout -B drift-repro efcbac73cc58510278b970949ac3b65cb9712815 && git merge --no-ff a73ff6a0e5174bd12c7e7e8fa626e1f304c84998
node scripts/docs-audit/affected-docs.mjs --json efcbac73cc58510278b970949ac3b65cb9712815
|
Fixes #22821
Clause-②: no
The Setup "Create User" and "Set Password" dialogs showed two controls for one decision: a "Generate Temporary Password" box and a password field labelled "leave empty to generate". With a password typed, the box did nothing, yet it went on the wire ticked. Now the password field's label is the only rule:
generatePasswordis no longer a dialog param on either action, and it rides in each action'sbodyExtraas a constanttrue. The endpoint's existing explicit-wins rule (resolvePassword) then gives exactly the label's behaviour.packages/plugins/plugin-auth/src/admin-user-endpoints.tsis not edited, and the endpoint's contract for other callers is unchanged.Measured before writing code (the dispatch's mechanism assumptions)
1. The action-param schema cannot express "never shown, still sent". The action schema can, with
bodyExtra. Read onorigin/mainb7cd1af9d,packages/spec/src/ui/action.zod.ts:visible(a param predicate): its own docs say the dialog omits the param when it is false. ThecarryOverdocs record thatvisible: falseomits the param from the dialog AND from the submission.carryOverneedsdefaultFromRow: true, andcreate_useris alist_toolbaraction with no row. It also renders a read-only summary the admin still sees.bodyExtra(onActionSchema) is "Static body fragment merged into the outgoing request body fortype:'api'actions. Useful for constants the user shouldn't (or can't) edit", applied after the collected params. ThecarryOverrefinement's own refusal points there: "(for a fixed value the user should not see) use the action'sbodyExtrainstead."2. The Console that
mainbundles drops a hidden param's value, and postsbodyExtraon every path these two actions use. Read in objectui at.objectui-sha20c6d351ad74d2b14a93becdc134d51b91b2d2e6:packages/app-shell/src/views/ActionParamDialog.tsx: defaults are seeded only forvisibleParams(the output offilterVisibleParams), and submit sendsserializeParamValues(visibleParams, values). A hidden param's default is never posted. So the suggested hidden-param route would have answered400to every admin who left the field empty.list_toolbar(create_user):ObjectViewbuilds anaction:bar.renderMemberspreads the whole action ontoaction:button, which forwardsbodyExtra: schema.bodyExtrato the runner. The mobile overflowaction:menuforwards it too.list_item(set_user_password):ObjectGrid'sonActionDefforwards the whole def (...rest).ActionRunner.execute) collects the params, then calls the console's registeredapihandler. InuseConsoleActionRuntime.tsxthat handler appliesObject.assign(body, resolvePageVarTokens(action.bodyExtra, pageVars))after the collected params andrecordIdParam. A boolean leaf passes throughresolvePageVarTokensunchanged.record_header(set_user_password):RecordDetailView'sapiHandlermergesaction.bodyExtrathe same way, afterrecordIdParam.resend_invitation(bodyExtra: { resend: true }) already sends a constant beside a params dialog.revoke_api_key/restore_api_keyandtransfer_ownership(bothlist_itemactions) sendbodyExtraconstants as their whole payload.Route. The route the seat chose, "a constant
truethe admin does not see; the endpoint is not edited", lands throughbodyExtrarather than through a hidden param. It touches the same file, the same two actions, and the declared translation bundles.Change
packages/platform-objects/src/identity/sys-user.object.ts:create_userandset_user_passwordlose thegeneratePasswordparam and gainbodyExtra: { generatePassword: true }. Thepassword/newPasswordlabels ("leave empty to generate") are unchanged, and they are now the only instruction on the dialog.packages/platform-objects/src/apps/translations/*.objects.generated.ts(4 files): regenerated withnode scripts/check-i18n-bundles.mjs --write. The only diff is the twogeneratePasswordlabel keys leaving each bundle (−6 lines per file). The other eight packages' bundles came back byte-identical.packages/plugins/plugin-auth/src/admin-user-endpoints.test.ts: the pins (below)..changeset/22821-admin-password-choice.md:@objectstack/platform-objectspatch.What the admin sees change. Create User: the box is gone, and the behaviour for an admin who left it ticked is unchanged. Set Password: the box defaulted to unticked there, so an empty field used to answer
400unless the admin ticked it. Now an empty field generates a password, which is what its label always said.Pins
These live in
plugin-auth. The cross-lane declaration on #6367 covers onlysys-user.object.tsand the generated bundles insidepackages/platform-objects, so no test file there is touched.plugin-authalready depends on@objectstack/platform-objectsand already imports@objectstack/platform-objects/identityin its tests.create_userandset_user_password, the dialog offers nogeneratePasswordparam, still offers the explicit password param, andbodyExtra.generatePassword === true.recordIdParam, thenbodyExtralast), then driven through the realrunAdminCreateUser/runAdminSetUserPassword.temporaryPasswordin the response.''): a temporary password is generated, applied, returned once, and leaked nowhere.set-user-passwordgains the three rowscreate-useralready had: explicit wins overgeneratePassword: true, empty plustruegenerates, and the CONTROL (neither field →400INVALID_REQUEST, nothing written). The existing create-user CONTROL row now asserts the envelopecodebeside the status.Verification (all at
a73ff6a0e)pnpm --filter @objectstack/plugin-auth exec vitest run --maxWorkers=2 src/admin-user-endpoints.test.ts: 52 passed (52).pnpm --filter @objectstack/plugin-auth exec vitest run --maxWorkers=2: 136 files, 2780 passed, 10 skipped.pnpm --filter @objectstack/platform-objects exec vitest run --maxWorkers=2: 69 files, 1082 passed.pnpm --filter @objectstack/platform-objects typecheckandpnpm --filter @objectstack/plugin-auth typecheck: exit 0.check:test-typecheckheld: plugin-auth 10 files / 94 errors / 23 signatures, unchanged.node scripts/pm/dispatch-gates.mjs --repo objectstack-ai/objectstack --ranreads "66 derived famil(ies) accounted for — 66 run, 0 NOT-MEASURED (a DERIVED zero — all 66 recorded an exit code and none of them is 3)".check-plugin-teardown-shape --self-testcould not read its pinned control commit in this shallow clone; after a depth-1 fetch of that commit it passed (48 cases).check:dual-build-cjs-loadsfound nine packages with nodist/; with those present it passed (107 entry points across 66 packages).check:dispatcher-error-vocabularyandcheck:error-status-conformance. Both exit 0.Ablations (each mutation committed-first, then restored and proven equal to HEAD)
Mutations went through
scripts/ablation-replace.mjs, with a bash trap restoring both paths on EXIT, INT and TERM. The pins readplatform-objectsthrough itsexports(itsdist/), so each metadata leg rebuilt it and proved the mutation reacheddist/withscripts/ablation-dist-preflight.mjsfirst.generatePasswordcontrol put back on both dialogs. On disk: 2 of 2. Indist/: present in 6 built files. Result: 2 failed / 50 passed,create_userandset_user_password"offers no generatePassword control", withAssertionError: expected [ Array(6) ] to not include 'generatePassword'.bodyExtraconstant removed from both actions. On disk: 0 left, 2 placeholders. Indist/: absent. Result: 6 failed / 46 passed. The two "sends it as a constant" rows failed, and so did the four "absent / empty generates" rows, because the endpoint answered400.generatePasswordas "generate" (=== truebecomes!== falseinresolvePassword). On disk: 1. Result: 2 failed / 50 passed, both CONTROL rows, withexpected 200 to be 400.git diff HEADis empty. The final run at HEAD: 52 passed (52).Acceptance notes
resolvePassword's docblock inadmin-user-endpoints.tsstill says "the console action dialog defaultsgeneratePassword: true". The value is now a constant, not a default. The rule it describes is still true. Not edited: the file is outside this claim. Whoever next edits that file can correct the wording; no one is lined up for it today.docs/qa/platform-checklist/areas/identity-auth.jsonthat drives create-user with an explicit password ANDgeneratePassword: true("the console dialog sends both") still describes the wire exactly.Generated by Claude Code