Skip to content

Commit d053c7d

Browse files
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
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
'@objectstack/plugin-auth': patch
3+
'@objectstack/platform-objects': patch
4+
---
5+
6+
feat(identity): the Add User result says when the address was already pending
7+
8+
Clause-②: yes (widening)
9+
Metadata-protocol: none
10+
11+
On a cloud-managed environment, Setup → Users → Add User now says when the address you added was already waiting for its first sign-in, including when you sent only an email. Before, that answer looked exactly like a fresh add.
12+
13+
- `POST /api/v1/auth/admin/add-sso-user` answers `pendingAgain: true` on a re-add of a person who is still pending, and leaves the key out on a fresh add. It never answers `false`. `alreadyPending` is unchanged and is still on every answer, so nothing an API reader reads today changes.
14+
- The `sys_user.add_sso_user` result dialog gains an "Already pending" row that reads `pendingAgain`. The dialog skips a field whose path is absent from the answer, so the row is drawn only on a re-add; a fresh add shows no `false` row.

‎packages/platform-objects/src/apps/translations/ar.objects.generated.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ export const arObjects: NonNullable<TranslationData['objects']> = {
240240
acknowledge: "تم",
241241
fields: {
242242
email: "البريد الإلكتروني",
243+
pendingAgain: "معلّق بالفعل",
243244
notApplied: "معلّق بالفعل، لذا لم يُطبَّق (عيّنه في السجل)",
244245
managerError: "المدير",
245246
"host.reason": "لم تُرسَل الدعوة"

‎packages/platform-objects/src/apps/translations/de.objects.generated.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ export const deObjects: NonNullable<TranslationData['objects']> = {
240240
acknowledge: "Fertig",
241241
fields: {
242242
email: "E-Mail",
243+
pendingAgain: "Bereits ausstehend",
243244
notApplied: "Bereits ausstehend, daher nicht übernommen (am Datensatz festlegen)",
244245
managerError: "Führungskraft",
245246
"host.reason": "Einladung nicht gesendet"

‎packages/platform-objects/src/apps/translations/en.objects.generated.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ export const enObjects: NonNullable<TranslationData['objects']> = {
240240
acknowledge: "Done",
241241
fields: {
242242
email: "Email",
243+
pendingAgain: "Already pending",
243244
notApplied: "Already pending, so not applied (set these on the record)",
244245
managerError: "Manager",
245246
"host.reason": "Invitation not sent"

‎packages/platform-objects/src/apps/translations/es-ES.objects.generated.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ export const esESObjects: NonNullable<TranslationData['objects']> = {
240240
acknowledge: "Hecho",
241241
fields: {
242242
email: "Correo electrónico",
243+
pendingAgain: "Ya pendiente",
243244
notApplied: "Ya estaba pendiente, así que no se aplicó (configúralo en el registro)",
244245
managerError: "Responsable",
245246
"host.reason": "Invitación no enviada"

‎packages/platform-objects/src/apps/translations/fr.objects.generated.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ export const frObjects: NonNullable<TranslationData['objects']> = {
240240
acknowledge: "Terminé",
241241
fields: {
242242
email: "E-mail",
243+
pendingAgain: "Déjà en attente",
243244
notApplied: "Déjà en attente, donc non appliqué (à définir sur l'enregistrement)",
244245
managerError: "Responsable",
245246
"host.reason": "Invitation non envoyée"

‎packages/platform-objects/src/apps/translations/ja-JP.objects.generated.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ export const jaJPObjects: NonNullable<TranslationData['objects']> = {
240240
acknowledge: "完了",
241241
fields: {
242242
email: "メールアドレス",
243+
pendingAgain: "既に保留中",
243244
notApplied: "保留中のため適用されませんでした(レコードで設定してください)",
244245
managerError: "上司",
245246
"host.reason": "招待は送信されませんでした"

‎packages/platform-objects/src/apps/translations/ko.objects.generated.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ export const koObjects: NonNullable<TranslationData['objects']> = {
240240
acknowledge: "완료",
241241
fields: {
242242
email: "이메일",
243+
pendingAgain: "이미 대기 중",
243244
notApplied: "이미 대기 중이어서 적용되지 않음(레코드에서 설정하세요)",
244245
managerError: "관리자",
245246
"host.reason": "초대가 전송되지 않음"

‎packages/platform-objects/src/apps/translations/pt-BR.objects.generated.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ export const ptBRObjects: NonNullable<TranslationData['objects']> = {
240240
acknowledge: "Concluído",
241241
fields: {
242242
email: "E-mail",
243+
pendingAgain: "Já pendente",
243244
notApplied: "Já pendente, então não aplicado (defina no registro)",
244245
managerError: "Gestor",
245246
"host.reason": "Convite não enviado"

‎packages/platform-objects/src/apps/translations/ru.objects.generated.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ export const ruObjects: NonNullable<TranslationData['objects']> = {
240240
acknowledge: "Готово",
241241
fields: {
242242
email: "Электронная почта",
243+
pendingAgain: "Уже ожидает",
243244
notApplied: "Уже ожидает входа, поэтому не применено (задайте в записи)",
244245
managerError: "Руководитель",
245246
"host.reason": "Приглашение не отправлено"

0 commit comments

Comments
 (0)