Repository navigation
Commit d053c7d
feat(plugin-auth): Add User says when a re-added address was already pending (#35162)
<!-- claude-projects-attribution: {"github_login":"os-warren"} -->
_Requested by **Warren** · [project
thread](https://claude.ai/code/project/chan_01U5RdnAAmkSQmZbqh6FtqZ8?thread=cmsg_01U5RdnAAmkSQmZbqh6FtqZ8AJJJRiYjshMUNgyMZSqBsr)_
Fixes #34651
Clause-②: yes (widening)
Metadata-protocol: none
## 维护者速读
- 改了什么:托管环境「设置 → 用户 → 添加用户」重加一个已在等激活的人时,结果弹窗多一行「已在待激活中」;正常新加时这一行不出现。
- 为什么改:以前只填邮箱重加一个等激活的人,结果和正常新加一模一样,管理员看不出此人早已在等;而直接读 `alreadyPending`
会在每次正常新加时画出一行「false」,裁决 A 不接受。
- 风险与回滚:只加不减。接口回答新增一个只在重加时出现的键 `pendingAgain: true`,`alreadyPending`
原样保留,现有 API 读者不受影响;回滚即 revert 本 PR。
-
先看:`packages/plugins/plugin-auth/src/pending-sso-users.ts`(`runAddSsoUser`
新增的一行条件展开)、`packages/platform-objects/src/identity/sys-user.object.ts`(`add_sso_user`
结果弹窗新增的字段)、`packages/plugins/plugin-auth/src/pending-sso-users.test.ts`(末尾两个新
describe)。
- 两分钟验证:`pnpm --filter @objectstack/plugin-auth exec vitest run
src/pending-sso-users.test.ts -t 34651`,预期 3 个用例全绿。
- 需要你做的:无,席位落地。
## What changes
- **plugin-auth `runAddSsoUser`**: on a re-add of an address that is
still pending, the answer gains `pendingAgain: true`. The key is absent
on a fresh add and is never `false`. `alreadyPending` is unchanged and
still on every answer, so this only widens the answer.
- **`sys_user.add_sso_user`**: the result dialog gains one field, `{
path: 'pendingAgain', label: 'Already pending', format: 'json' }`. The
dialog skips a field whose path resolves to nothing, so the row shows
only on a re-add. The label is translated in the ten platform-objects
bundles, the same way the dialog's other fields are labelled
(`resultDialog.fields.PATH`). The bundles were regenerated with `node
scripts/check-i18n-bundles.mjs --write`, and the translated values were
written by hand. Each translation is the "already pending" half of the
locale's existing `summary.alreadyPending` string.
- **Root `.changeset/`**: patch for `@objectstack/plugin-auth` and
`@objectstack/platform-objects`, with the two declaration lines
line-initial.
**Why `pendingAgain`.** The card leaves the name to precedent. The
precedent is the parent card's dev report (6938771548, open question 1,
option B, "for example pendingAgain: true"). The seat ruled for that
option when it filed this card, and `pendingAgain` is one of the card's
dedupe words. The answer's shape follows this file's own precedent:
`notApplied` is also present only on a re-add. It also follows the
repo's flag-present-only-when-true shape `...(cond ? { key: true } :
{})`, which `servedOverride: true`
(`packages/metadata-protocol/src/protocol-meta-item-reads.ts`) and
`truncated: true` (`packages/mcp/src/mcp-http-tools.ts`) use too.
**Why the dialog skips the field on a fresh add.**
`ui/packages/app-shell/src/views/ActionResultDialog.tsx` maps each
declared field to `readPath(data, field.path)`, then runs `.filter(({
field, value }) => field.path === '' || value !== undefined)`. A path
missing from the answer resolves to `undefined` and is dropped (the
header contract says the same). `format: 'json'` is used because the
value is a boolean: `valueFitsFormat` gives `text` a string only, and
anything else falls back to `json` anyway.
**The released sentence.** In `packages/platform-objects/CHANGELOG.md`,
18.5.0, entry 2e1e3b9, the sentence "The Add User result names an
address that was already pending" was untrue for an email-only re-add.
Once this lands it is true: the result shows "Already pending" on every
re-add, including one that sends only an email.
## Tests
On head 0ad415b:
- **Door pin** (`pending-sso-users.test.ts`, describe `[#34651]
add-sso-user says a re-added address was already pending, and only
then`): an email-only re-add answers 200 with `pendingAgain` `true` (and
`alreadyPending` `true`). CONTROL: a fresh add answers 201 with no
`pendingAgain` property.
- **Alignment pin** (same file, describe `[#34651] the import result
table reads members of a real row answer`): the test stages the import
door with a fresh add whose manager is unknown, a malformed address and
a re-add that sends a column. It asserts that the first segment of every
column path of `sys_user.import_sso_users`'s `table` field is a member
of a real row answer.
- **sys_user pin** (`cloud-managed-visibility.test.ts`, describe
`add_sso_user names an address that was already pending`):
`add_sso_user` declares exactly one field reading `pendingAgain` (label
and format pinned). CONTROL: no field reads `alreadyPending`.
- Package runs, each through the verify lock: plugin-auth `vitest run`
285 files, 5997 passed, 10 skipped; platform-objects `vitest run` 123
files, 2047 passed; `typecheck` for both packages exit 0 (test layers
included through `check:test-typecheck`).
<details><summary>Ablations (scripts/ablation-replace.mjs; each leg
restored, blob == HEAD and git diff HEAD empty)</summary>
The tests import `pending-sso-users.ts` and `sys-user.object.ts` by
relative path, so the source is what runs and no `dist/` step applies.
- A1, door key deleted (`...(outcome.alreadyPending ? { pendingAgain:
true } : {}),`, anchor 1 to 0): `-t 34651` gave 1 failed and 2 passed.
The re-add pin was red, and the two controls (fresh add, alignment)
stayed green.
- A2, sys_user field deleted (anchor 1 to 0): 1 failed and 1 passed. The
`pendingAgain` field pin was red and the control stayed green.
- A3, import row member `notApplied` deleted from the door's row answer
(anchor 1 to 0): the alignment pin failed with `expected [ 'notApplied'
] to deeply equal []`.
</details>
## Acceptance notes
- `content/docs/permissions/authentication.mdx` line 1340 says the add
door "answers `201`, or `200` with `alreadyPending`". It does not
mention `pendingAgain`. That is outside this card's file surface, and
the sentence is still true.
- The label is "Already pending", not the import table's "Already
pending, told again". A re-add of a deactivated pending person also
answers `pendingAgain`, but no invitation is sent then (`host.reason`
reads `deactivated`), so "told again" would be wrong there. The import
table's `alreadyPending` column and `summary.alreadyPending` already use
"told again" for that same deactivated row. This PR leaves them as they
are.
- The plugin-auth alignment pin reads `SysUser` through
`@objectstack/platform-objects/identity`, which resolves to that
package's `dist/` (a listed unaliased pair in
`check-test-source-alias`). CI builds it first.
## Verification
<details><summary>Local gates on 0ad415b</summary>
- `node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack` derived 73 commands against merge base
3446f23. Each was run with stdin closed, and its exit code was
captured before any pipe.
- 71 exited 0 on the first run.
- `node scripts/check-plugin-teardown-shape.mjs --self-test` first
exited 3 because its fixture commit 621a487 was missing from the
shallow clone. After a depth-1 fetch of that commit it exited 0 ("48
cases pass").
- NOT MEASURED: `pnpm check:dual-build-cjs-loads` exited 3 (PREREQUISITE
NOT MET: it needs a whole-workspace build). This narrowing is declared;
Lint & Repo Gates runs it in CI.
- `--ran` reconciliation: "73 derived famil(ies) accounted for — 72 run,
1 NOT-MEASURED (1 DERIVED from a recorded exit 3)".
- `node scripts/check-i18n-bundles.mjs --filter=platform-objects`: exit
0, "all bundles in sync".
- `node scripts/pm/overlap-check.mjs --repo=objectstack-ai/objectstack`:
exit 0, "VERDICT clean". It merges cleanly with origin/main 3483407
and with #34717, which shares the translation bundles and
`sys-user.object.ts`.
- Build: `pnpm --filter '@objectstack/plugin-auth^...' build` VERDICT
command-exit 0, then `turbo run build --filter=@objectstack/cli
--filter=@objectstack/platform-objects` VERDICT command-exit 0.
</details>
---
_Generated by [Claude
Code](https://claude.ai/code/session_01JQwxbYRqkDAGuse5Wqbohi)_
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 2df9691 commit d053c7d
16 files changed
Lines changed: 133 additions & 3 deletions
File tree
- .changeset
- packages
- platform-objects/src
- apps/translations
- identity
- plugins/plugin-auth/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
240 | 240 | | |
241 | 241 | | |
242 | 242 | | |
| 243 | + | |
243 | 244 | | |
244 | 245 | | |
245 | 246 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
240 | 240 | | |
241 | 241 | | |
242 | 242 | | |
| 243 | + | |
243 | 244 | | |
244 | 245 | | |
245 | 246 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
240 | 240 | | |
241 | 241 | | |
242 | 242 | | |
| 243 | + | |
243 | 244 | | |
244 | 245 | | |
245 | 246 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
240 | 240 | | |
241 | 241 | | |
242 | 242 | | |
| 243 | + | |
243 | 244 | | |
244 | 245 | | |
245 | 246 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
240 | 240 | | |
241 | 241 | | |
242 | 242 | | |
| 243 | + | |
243 | 244 | | |
244 | 245 | | |
245 | 246 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
240 | 240 | | |
241 | 241 | | |
242 | 242 | | |
| 243 | + | |
243 | 244 | | |
244 | 245 | | |
245 | 246 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
240 | 240 | | |
241 | 241 | | |
242 | 242 | | |
| 243 | + | |
243 | 244 | | |
244 | 245 | | |
245 | 246 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
240 | 240 | | |
241 | 241 | | |
242 | 242 | | |
| 243 | + | |
243 | 244 | | |
244 | 245 | | |
245 | 246 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
240 | 240 | | |
241 | 241 | | |
242 | 242 | | |
| 243 | + | |
243 | 244 | | |
244 | 245 | | |
245 | 246 | | |
| |||
0 commit comments