Skip to content

Commit 319d6fa

Browse files
feat(ui): the signed-out invitation landing names the inviter and the organization from the invitation preview (#26554)
Fixes #26473 Clause-②: no Metadata-protocol: none ## 维护者速读 - **改了什么:** 未登录时打开邀请链接,登录页与注册页会读取服务端的匿名邀请预览(`GET /api/v1/auth/organization/invitation-preview`),卡片标题变为「林晓 邀请你加入 晓林装饰工作室」,并显示打码后的受邀邮箱作为提示。 - **为什么改:** 服务端读取已在 #26020 落地,但没有任何页面调用它;受邀人在注册前看不到是谁、邀请加入哪个组织。 - **风险与回滚:** 低。邮箱是打码值,只作提示,从不预填;预览 404、读取失败或旧服务端都保留现有通用文案,不抛错。回滚即 revert 本 PR。 - **先看:** `ui/packages/app-shell/src/console/auth/invitationArrival.tsx` 的 `useInvitationPreview` 与 `invitationArrivalCopy`;`ui/packages/auth/src/createAuthClient.ts` 的 `getInvitationPreview`。 - **两分钟验证:** `pnpm --dir ui exec vitest run packages/app-shell/src/console/auth/__tests__/invitationPreview-26473.test.tsx packages/auth/src/__tests__/invitationPreview-26473.test.ts`,预期全绿。 - **需要你做的:** 无,席位落地。 ## What changes **`@object-ui/auth`.** `getInvitationPreview(invitationId)` is added to `AuthClient`, `AuthContextValue`, `AuthProvider` and `useAuth()`, along with the exported `AuthInvitationPreview` type (`organizationName`, `inviterName: string | null`, `email`). The client sends one anonymous `GET {authUrl}/organization/invitation-preview?id=ID` with the id URL-encoded. It handles the answers this way: - 200 with `{ success: true, data }`: the three keys, checked at the boundary. - 404: `null`. The server sends one uniform not-found for an unknown, expired, accepted, rejected or cancelled id, so this is an answer, not a failure. - Any other status: a rejection that carries the server's `code` and the HTTP `status`. - A 200 of the wrong shape: a rejection named `getInvitationPreview`. The page never gets a half-filled sentence. **`@object-ui/app-shell`.** `invitationArrival.tsx` gains `useInvitationPreview(redirect)` and `invitationArrivalCopy(page, preview, t)`, and both are exported from the package entry. - The hook reads the id from `?redirect=/accept-invitation/ID`, using the same segment `isInvitationRedirect` tests. It returns the preview for the current id only. It returns `null` while the read is pending, for a 404, and after any failure, including a `useAuth()` double that lacks the method. None of these throws into the page. - The copy helper returns the title and description for the login or register card. When there is a preview, the title is "INVITER invited you to join ORG", or "You are invited to join ORG" when the inviter has no name, and the description shows the masked address as the one to use. Without a preview it returns the generic copy each page shows today. - `DefaultLoginPage` and `DefaultRegisterPage` use both for an invitation redirect. **`@object-ui/console`.** The console's own `/login` and `/register` (`apps/console/src/pages/auth/`) do the same. They are the pages the console routes. **The masked email.** The preview's `email` is masked by the server (`z***@example.com`). It appears only in the card's description. No field is filled from it, and the pins assert that the email input stays empty. **`@object-ui/i18n`.** Four keys are added: `auth.login.invitationPreviewTitle`, `auth.login.invitationPreviewTitleNoInviter`, `auth.login.invitationPreviewDescription` and `auth.register.invitationPreviewDescription`. ## Locale packs: all ten, not en and zh only The dispatch asked for new strings in en and zh only. That was measured, and it reds `ui/packages/i18n/src/__tests__/all-locales-key-parity.test.ts`. That test requires every pack to define every en key, and its only exception is the four outbound AI-message keys. The run under the lock with en and zh only: `Tests 8 failed | 40 passed (48)`, one failure per other locale, for example `ar is missing 4 key(s): auth.login.invitationPreviewDescription, auth.login.invitationPreviewTitle, auth.login.invitationPreviewTitleNoInviter, auth.register.invitationPreviewDescription`. So the four keys are added to ar, de, es, fr, ja, ko, pt and ru as well, each on its own new lines next to the existing invitation keys. - No existing value is changed. - The en pack's comment above the invitation keys is updated, because it said the copy names no organization. - Seat 1's #26469 also edits these packs. A conflict there would be one of line placement only. ## Tests (red first) New files: - `ui/packages/auth/src/__tests__/invitationPreview-26473.test.ts` (5 tests). Cases: found (exact keys, one GET, encoded id); found with a null inviter; 404 resolves `null`; 429 rejects with `code` and `status`; a wrong-shape 200 rejects. - `ui/packages/app-shell/src/console/auth/__tests__/invitationPreview-26473.test.tsx` covers `DefaultLoginPage` and `DefaultRegisterPage`, rendered through a real `AuthProvider`, a real `createAuthClient` and a real `I18nProvider`, with only `fetch` stubbed. Cases: - found: inviter and organization in the heading, the masked address shown, the email field empty; - found without an inviter; - 404: generic copy; - failed reads (500, a network failure, a wrong-shape body): generic copy, and the form still renders; - a login that did not come from an invitation sends no preview request. - `ui/apps/console/src/pages/auth/__tests__/invitationPreview-26473.test.tsx` runs found, 404 and 500 on the console's `/login` and `/register`. The red leg was run under the lock: the 14 implementation files were restored to the base `00a4593a` in the working tree only, the new files were run, and then the files were restored to `HEAD`. The restore was proved by hash comparison and an empty `git diff HEAD`. Red, with the implementation at base: - auth file: 5 of 5 tests fail (`client.getInvitationPreview is not a function`). - app-shell file: 9 of 10 fail. The one that passes is the preservation pin (no preview request without an invitation redirect), which is expected to pass at base. - console file: 6 of 6 fail. Green at head: see Verification. ## Acceptance notes - `invitationIdOf` in `invitationArrival.tsx` reads the same `/accept-invitation/` segment as `isInvitationRedirect` in `signUpOffer.ts`. That file is in open PR #26483 and was not touched here. Once #26483 lands, `isInvitationRedirect` could be expressed as `invitationIdOf(r) !== null`, leaving one parser. - The card also suggests a warning when the typed address does not match the masked pattern. The seat's route did not include it, so it is not done here. The masked address is shown, and the server still refuses a non-invitee's sign-up. - The card's optional "greet from ObjectOS Cloud" on the environment host is not taken. It is a matter of taste and outside the seat's route. - `AcceptInvitationPage` is unchanged. A signed-out visitor is redirected from it to `/login` before it renders, and a signed-in visitor already gets the organization through `get-invitation`. - The claim's file surface named `invitationArrival.tsx`, `AcceptInvitationPage.tsx`, the console sign-up page, `createAuthClient.ts` and the locale packs. This diff also touches four files the card itself lists (both `LoginPage.tsx` files and both `RegisterPage.tsx` files), the auth package's `types.ts`, `AuthContext.ts`, `AuthProvider.tsx`, `useAuth.ts` and `index.ts` (needed to reach the read from a page), the app-shell `index.ts` export, and all ten locale packs. ## Verification All runs are on head `b848d2b1`, in a worktree based on `origin/main` `00a4593a`. Heavy runs went through `scripts/pm/os-verify-lock.sh`. - Closure: `pnpm --workspace-concurrency=2 --filter '@object-ui/console^...' build` gave `VERDICT command-exit 0`. - `vitest run` (from `ui/`) over `packages/auth/`, `packages/i18n/` and the 13 app-shell test files that import the touched pages (the new file included): `Test Files 136 passed (136)`, `Tests 1781 passed | 13 skipped (1794)`. - Console project, over the 21 console test files that import the two console pages (the new file included): `Test Files 21 passed (21)`, `Tests 110 passed (110)`. - `pnpm --filter X run type-check` exited 0 for each of `@object-ui/auth`, `@object-ui/i18n`, `@object-ui/app-shell` and `@object-ui/console`. - ui i18n gates `check:i18n-keys` (it checks every inline `defaultValue` against the en pack), `check:i18n-drift` and `check:i18n-dead-keys`: exit 0. - `node scripts/check-sdui-manifest.mjs`: exit 0. No registry component contract changed, so the manifest is not regenerated. - Derived gates (`dispatch-gates.mjs --commands`): 34 commands. 32 exited 0. Two were not measured, and CI runs both: - `pnpm --dir ui exec vitest run scripts/` exited 99, a lock queue-timeout, three times. - `pnpm check:type-check-debt` exited 3, PREREQUISITE NOT MET, because its re-measure build never got a lock turn. The four touched packages' own type-checks are green above. The `--ran` reconciliation reads 34 accounted, 33 run, 1 NOT-MEASURED. The tool classifies exit 3 only, so the exit-99 vitest run counts as NOT MEASURED here as well. - `pnpm check:changeset-fixed` and `pnpm check:nul-bytes`: exit 0. --- _Generated by [Claude Code](https://claude.ai/code/session_01SMps7wq7rBTk53e8KTSEup)_ --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent a98693d commit 319d6fa

26 files changed

Lines changed: 809 additions & 46 deletions
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
'@object-ui/auth': patch
3+
'@object-ui/app-shell': patch
4+
'@object-ui/i18n': patch
5+
'@object-ui/console': patch
6+
---
7+
8+
feat(auth,app-shell,i18n,console): an invitation link opened signed out names the inviter and the organization on the sign-in and sign-up pages
9+
10+
Clause-②: no
11+
Metadata-protocol: none
12+
13+
A visitor who opened an invitation link while signed out landed on 「接受邀请 · 请使用收到邀请的邮箱。」 and then 「注册账号并加入」, and neither page said who had invited them or to which organization. The server has answered that question anonymously since `GET /api/v1/auth/organization/invitation-preview?id=ID`, but no page read it.
14+
15+
- **`@object-ui/auth`:** `getInvitationPreview(invitationId)` on the auth client, `AuthProvider` and `useAuth()`, with the `AuthInvitationPreview` type (`organizationName`, `inviterName`, `email`). It needs no session. It resolves the preview, resolves `null` for the server's not-found answer, and rejects with the server's `code` and the HTTP `status` on any other failure.
16+
- **`@object-ui/app-shell`:** `useInvitationPreview(redirect)` and `invitationArrivalCopy(page, preview, t)`. `DefaultLoginPage` and `DefaultRegisterPage` use them for a visitor arriving from `/accept-invitation/ID`, and the card reads 「林晓 邀请你加入 晓林装饰工作室」. The masked invited address (`z***@example.com`) is shown as the address to use. It never fills the email field, because a masked value is not an address. An unknown or expired invitation, a failed read, or a server without the route keeps the generic copy.
17+
- **`@object-ui/console`:** the console's own `/login` and `/register` do the same.
18+
- **`@object-ui/i18n`:** `auth.login.invitationPreviewTitle`, `auth.login.invitationPreviewTitleNoInviter`, `auth.login.invitationPreviewDescription` and `auth.register.invitationPreviewDescription`, in all ten locale packs.
19+
20+
What to do: nothing. A host that mocks `useAuth()` without `getInvitationPreview` keeps the generic invitation copy.

‎ui/apps/console/src/pages/auth/LoginPage.tsx‎

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@
3030
* (`?redirect=/accept-invitation/ID`) is greeted for that invitation instead
3131
* of as a returning user, and, where sign-up is offered, gets app-shell's
3232
* `InvitationSignUpPrompt` above the form in place of the small "Sign up"
33-
* link — the same prompt `DefaultLoginPage` shows (#25886).
33+
* link — the same prompt `DefaultLoginPage` shows (#25886). The greeting
34+
* names the organization and the inviter when the signed-out invitation
35+
* preview answers, with the masked invited address as the one to use (#26473,
36+
* app-shell's `useInvitationPreview`); otherwise it keeps the generic copy.
3437
*
3538
* Layout (objectui#12600): one 400 px column — brand mark, the card, a footer.
3639
* The card carries this page's own two-line header, so `<LoginForm>` renders
@@ -60,6 +63,8 @@ import {
6063
needsBootstrapProbe,
6164
useBootstrapStatus,
6265
InvitationSignUpPrompt,
66+
invitationArrivalCopy,
67+
useInvitationPreview,
6368
} from '@object-ui/app-shell';
6469
import { AuthLayout } from './AuthLayout';
6570
import { AuthFooter, readLegalLinks } from './AuthFooter';
@@ -153,6 +158,11 @@ export function LoginPage() {
153158
hasBootstrapped && !user && needsBootstrapProbe(authConfig, invitationRedirect),
154159
);
155160
const signUpOffer = decideSignUpOffer(authConfig, { invitationRedirect, bootstrap });
161+
// #26473 — who invited this visitor, and to what; `null` keeps the generic copy.
162+
const invitationPreview = useInvitationPreview(redirect);
163+
const invitationCopy = invitationRedirect
164+
? invitationArrivalCopy('login', invitationPreview, t)
165+
: null;
156166

157167
// Detect SSO hand-off so we can surface the relying-party host.
158168
const ssoTarget = useMemo(() => {
@@ -327,15 +337,13 @@ export function LoginPage() {
327337
<>
328338
<div className="mb-5">
329339
<h1 className="text-xl font-semibold tracking-tight text-foreground">
330-
{invitationRedirect
331-
? t('auth.login.invitationTitle', { defaultValue: 'Accept your invitation' })
340+
{invitationCopy
341+
? invitationCopy.title
332342
: t('auth.login.welcomeTitle', { defaultValue: 'Welcome back' })}
333343
</h1>
334344
<p className="mt-1 text-[13px] text-muted-foreground">
335-
{invitationRedirect
336-
? t('auth.login.invitationDescription', {
337-
defaultValue: 'Use the email address the invitation was sent to.',
338-
})
345+
{invitationCopy
346+
? invitationCopy.description
339347
: t('auth.login.welcomeDescription', {
340348
defaultValue: 'Sign in to continue your work',
341349
})}

‎ui/apps/console/src/pages/auth/RegisterPage.tsx‎

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ import {
4040
isInvitationRedirect,
4141
needsBootstrapProbe,
4242
useBootstrapStatus,
43+
invitationArrivalCopy,
44+
useInvitationPreview,
4345
} from '@object-ui/app-shell';
4446
import { AuthLayout } from './AuthLayout';
4547
import { followOauthAuthorize } from './followAuthorize';
@@ -138,6 +140,11 @@ export function RegisterPage() {
138140
needsBootstrapProbe(authConfig, invitationRedirect),
139141
);
140142
const signUpOffer = decideSignUpOffer(authConfig, { invitationRedirect, bootstrap });
143+
// #26473 — who invited this visitor, and to what; `null` keeps the generic copy.
144+
const invitationPreview = useInvitationPreview(redirect);
145+
const invitationCopy = invitationRedirect
146+
? invitationArrivalCopy('register', invitationPreview, t)
147+
: null;
141148

142149
// Sign-up switched off — bounce to /login.
143150
useEffect(() => {
@@ -263,18 +270,17 @@ export function RegisterPage() {
263270
<Card className="border-border/60 px-4 py-8 shadow-sm shadow-primary/5 backdrop-blur supports-[backdrop-filter]:bg-card/95">
264271
<RegisterForm
265272
// #25886 — an invitee is told to register the invited address: the
266-
// invitation is accepted only by the account that carries it.
273+
// invitation is accepted only by the account that carries it. #26473 —
274+
// with the preview, the card names the inviter and the organization,
275+
// and shows the masked address; the email field stays empty.
267276
title={
268-
invitationRedirect
269-
? t('auth.register.invitationTitle', { defaultValue: 'Create an account to join' })
277+
invitationCopy
278+
? invitationCopy.title
270279
: t('auth.register.title', { defaultValue: 'Create an account' })
271280
}
272281
description={
273-
invitationRedirect
274-
? t('auth.register.invitationDescription', {
275-
defaultValue:
276-
'Register with the email address the invitation was sent to. The invitation can only be accepted with that address.',
277-
})
282+
invitationCopy
283+
? invitationCopy.description
278284
: t('auth.register.description', {
279285
defaultValue: 'Create your account to start building.',
280286
})
Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
/**
2+
* #26473 — the console's own `/login` and `/register`, opened signed out from
3+
* an invitation link, greet the visitor by WHO invited them and to WHAT.
4+
*
5+
* The read is app-shell's `useInvitationPreview` over the server's signed-out
6+
* `GET {authUrl}/organization/invitation-preview?id=ID`; the package's default
7+
* pages carry the same pins in
8+
* `packages/app-shell/src/console/auth/__tests__/invitationPreview-26473.test.tsx`.
9+
* Pinned here for the pages the console actually routes:
10+
*
11+
* - found: the card names the inviter and the organization and shows the
12+
* MASKED address as the one to use; the email field stays empty;
13+
* - 404: today's generic invitation copy;
14+
* - a failed read: today's generic copy too, and the form still renders.
15+
*
16+
* Rendered with a real `AuthProvider` over a real `createAuthClient`; only
17+
* `fetch` is a stub. Generic copy is read from the en pack.
18+
*/
19+
20+
import '@testing-library/jest-dom/vitest';
21+
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
22+
import { act, render, screen, cleanup, waitFor } from '@testing-library/react';
23+
import { MemoryRouter, Routes, Route } from 'react-router-dom';
24+
import { I18nProvider } from '@object-ui/i18n';
25+
import { builtInLocales } from '@object-ui/i18n/locales';
26+
import { AuthProvider, createAuthClient } from '@object-ui/auth';
27+
import type { AuthPublicConfig } from '@object-ui/auth';
28+
import { LoginPage } from '../LoginPage';
29+
import { RegisterPage } from '../RegisterPage';
30+
31+
const AUTH_URL = 'http://localhost/api/v1/auth';
32+
const en = builtInLocales.en.auth;
33+
const INVITATION_ID = 'inv_26473';
34+
const INVITE_QUERY = `?redirect=${encodeURIComponent(`/accept-invitation/${INVITATION_ID}`)}`;
35+
const ORG = 'Xiaolin Decoration Studio';
36+
const INVITER = 'Lin Xiao';
37+
const MASKED = 'z***@example.com';
38+
const MASKED_TEXT = new RegExp(MASKED.replace(/[*.]/g, '\\$&'));
39+
40+
const CONFIG: AuthPublicConfig = {
41+
emailPassword: { enabled: true, disableSignUp: false, requireEmailVerification: false },
42+
features: { audiencePosture: 'invite_only' },
43+
};
44+
45+
type PreviewAnswer = 'found' | 404 | 500;
46+
let previewRequests: string[];
47+
48+
function stubServer(answer: PreviewAnswer): typeof fetch {
49+
previewRequests = [];
50+
const json = (body: unknown, status = 200) =>
51+
new Response(JSON.stringify(body), { status, headers: { 'Content-Type': 'application/json' } });
52+
return (async (input: string | URL | Request) => {
53+
const url = typeof input === 'string' ? input : input instanceof URL ? input.href : input.url;
54+
if (url.includes('/organization/invitation-preview')) {
55+
previewRequests.push(url);
56+
if (answer === 'found') {
57+
return json({ success: true, data: { organizationName: ORG, inviterName: INVITER, email: MASKED } });
58+
}
59+
return json(
60+
{
61+
success: false,
62+
error:
63+
answer === 404
64+
? { code: 'RESOURCE_NOT_FOUND', message: 'Invitation not found.' }
65+
: { code: 'INTERNAL_ERROR', message: 'The invitation preview is unavailable.' },
66+
},
67+
answer,
68+
);
69+
}
70+
if (url.endsWith('/bootstrap-status')) return json({ hasOwner: true });
71+
if (url.endsWith('/config')) return json({ success: true, data: CONFIG });
72+
return json(null);
73+
}) as typeof fetch;
74+
}
75+
76+
function renderAt(path: string, answer: PreviewAnswer) {
77+
const fetchFn = stubServer(answer);
78+
vi.stubGlobal('fetch', fetchFn);
79+
window.history.replaceState({}, '', path);
80+
const client = createAuthClient({ baseURL: AUTH_URL, fetchFn });
81+
return render(
82+
<I18nProvider config={{ defaultLanguage: 'en', detectBrowserLanguage: false }} persistLanguage={false}>
83+
<AuthProvider authUrl={AUTH_URL} client={client}>
84+
<MemoryRouter initialEntries={[path]}>
85+
<Routes>
86+
<Route path="/login" element={<LoginPage />} />
87+
<Route path="/register" element={<RegisterPage />} />
88+
</Routes>
89+
</MemoryRouter>
90+
</AuthProvider>
91+
</I18nProvider>,
92+
);
93+
}
94+
95+
async function previewAnswered() {
96+
await waitFor(() => expect(previewRequests).toHaveLength(1));
97+
await act(async () => {
98+
await new Promise((resolve) => setTimeout(resolve, 0));
99+
});
100+
}
101+
102+
beforeEach(() => {
103+
window.localStorage.clear();
104+
vi.spyOn(console, 'warn').mockImplementation(() => {});
105+
});
106+
107+
afterEach(() => {
108+
cleanup();
109+
vi.unstubAllGlobals();
110+
vi.restoreAllMocks();
111+
window.history.replaceState({}, '', '/');
112+
});
113+
114+
describe('console /login — the invitation landing reads the signed-out preview (#26473)', () => {
115+
it('found: names the inviter and the organization, shows the masked address, prefills nothing', async () => {
116+
renderAt(`/login${INVITE_QUERY}`, 'found');
117+
118+
const heading = await screen.findByRole('heading', { name: new RegExp(ORG) });
119+
expect(heading).toHaveTextContent(INVITER);
120+
expect(screen.getByText(MASKED_TEXT)).toBeInTheDocument();
121+
expect(screen.queryByRole('heading', { name: en.login.invitationTitle })).toBeNull();
122+
expect(previewRequests).toEqual([`${AUTH_URL}/organization/invitation-preview?id=${INVITATION_ID}`]);
123+
expect(await screen.findByLabelText(en.login.emailLabel)).toHaveValue('');
124+
});
125+
126+
it('404: keeps the generic invitation copy', async () => {
127+
renderAt(`/login${INVITE_QUERY}`, 404);
128+
await previewAnswered();
129+
130+
expect(await screen.findByRole('heading', { name: en.login.invitationTitle })).toBeInTheDocument();
131+
expect(screen.queryByText(new RegExp(ORG))).toBeNull();
132+
});
133+
134+
it('a failed read: keeps the generic copy and the sign-in form', async () => {
135+
renderAt(`/login${INVITE_QUERY}`, 500);
136+
await previewAnswered();
137+
138+
expect(await screen.findByRole('heading', { name: en.login.invitationTitle })).toBeInTheDocument();
139+
expect(await screen.findByLabelText(en.login.emailLabel)).toBeInTheDocument();
140+
});
141+
});
142+
143+
describe('console /register — the sign-up step reads the same preview (#26473)', () => {
144+
it('found: names the inviter and the organization, shows the masked address, prefills nothing', async () => {
145+
renderAt(`/register${INVITE_QUERY}`, 'found');
146+
147+
const heading = await screen.findByRole('heading', { name: new RegExp(ORG) });
148+
expect(heading).toHaveTextContent(INVITER);
149+
expect(screen.getByText(MASKED_TEXT)).toBeInTheDocument();
150+
expect(screen.getByLabelText(en.register.emailLabel)).toHaveValue('');
151+
});
152+
153+
it('404: keeps the generic invitation copy', async () => {
154+
renderAt(`/register${INVITE_QUERY}`, 404);
155+
await previewAnswered();
156+
157+
expect(await screen.findByRole('heading', { name: en.register.invitationTitle })).toBeInTheDocument();
158+
});
159+
160+
it('a failed read: keeps the generic copy and the form', async () => {
161+
renderAt(`/register${INVITE_QUERY}`, 500);
162+
await previewAnswered();
163+
164+
expect(await screen.findByRole('heading', { name: en.register.invitationTitle })).toBeInTheDocument();
165+
expect(screen.getByLabelText(en.register.emailLabel)).toBeInTheDocument();
166+
});
167+
});

‎ui/packages/app-shell/src/console/auth/LoginPage.tsx‎

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919
* is greeted for that invitation instead of as a returning user, and, where
2020
* sign-up is offered, gets `InvitationSignUpPrompt` (`./invitationArrival`)
2121
* above the form in place of the small "Sign up" link (#25886). The console's
22-
* own login page does the same.
22+
* own login page does the same. The greeting names the organization and the
23+
* inviter when the signed-out invitation preview answers (#26473,
24+
* `useInvitationPreview`), and keeps the generic copy when it does not.
2325
*/
2426

2527
import { useEffect, useState } from 'react';
@@ -39,7 +41,11 @@ import { AuthPageLayout } from './AuthPageLayout.js';
3941
import { signInRefusalMessages } from './signInRefusalMessages.js';
4042
import { decideSignUpOffer, isInvitationRedirect, needsBootstrapProbe } from './signUpOffer.js';
4143
import { useBootstrapStatus } from './bootstrapStatus.js';
42-
import { InvitationSignUpPrompt } from './invitationArrival.js';
44+
import {
45+
InvitationSignUpPrompt,
46+
invitationArrivalCopy,
47+
useInvitationPreview,
48+
} from './invitationArrival.js';
4349

4450
const RouterLink = ({ href, className, children }: AuthLinkComponentProps) => (
4551
<Link to={href} className={className}>{children}</Link>
@@ -120,6 +126,8 @@ export function LoginPage() {
120126
// did not come from an invitation; see `./signUpOffer`.
121127
const invitationRedirect = isInvitationRedirect(redirect);
122128
const bootstrap = useBootstrapStatus(!user && needsBootstrapProbe(authConfig, invitationRedirect));
129+
// #26473 — who invited this visitor, and to what; `null` keeps the generic copy.
130+
const invitationPreview = useInvitationPreview(redirect);
123131
const signUpOffer = decideSignUpOffer(authConfig, { invitationRedirect, bootstrap });
124132

125133
// Carry `?redirect=` into the sign-up link: it is how `/register` knows the
@@ -195,16 +203,15 @@ export function LoginPage() {
195203

196204
if (!invitationRedirect) return <AuthPageLayout>{form}</AuthPageLayout>;
197205

206+
const invitationCopy = invitationArrivalCopy('login', invitationPreview, t);
207+
198208
return (
199209
<AuthPageLayout>
200210
<div
201211
data-testid="login-invitation-arrival"
202212
className="mx-auto flex w-full flex-col justify-center space-y-6 sm:max-w-[400px]"
203213
>
204-
<AuthFormHeader
205-
title={t('auth.login.invitationTitle')}
206-
description={t('auth.login.invitationDescription')}
207-
/>
214+
<AuthFormHeader title={invitationCopy.title} description={invitationCopy.description} />
208215
{invitationSignUpUrl ? <InvitationSignUpPrompt registerUrl={invitationSignUpUrl} /> : null}
209216
{form}
210217
</div>

‎ui/packages/app-shell/src/console/auth/RegisterPage.tsx‎

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ import { signUpRefusalMessages } from './signUpRefusalMessages.js';
4242
import { decideSignUpOffer, isInvitationRedirect, needsBootstrapProbe } from './signUpOffer.js';
4343
import { useBootstrapStatus } from './bootstrapStatus.js';
4444
import { ServerUnreachable } from './LoginPage.js';
45+
import { invitationArrivalCopy, useInvitationPreview } from './invitationArrival.js';
4546

4647
const RouterLink = ({ href, className, children }: AuthLinkComponentProps) => (
4748
<Link to={href} className={className}>{children}</Link>
@@ -105,6 +106,8 @@ export function RegisterPage() {
105106
const signedOut = sessionChecked && !user;
106107
const bootstrap = useBootstrapStatus(signedOut && needsBootstrapProbe(authConfig, invitationRedirect));
107108
const signUpOffer = decideSignUpOffer(authConfig, { invitationRedirect, bootstrap });
109+
// #26473 — who invited this visitor, and to what; `null` keeps the generic copy.
110+
const invitationPreview = useInvitationPreview(redirect);
108111

109112
// Sign-up switched off — bounce a signed-out visitor to /login, keeping
110113
// `?redirect=`. A signed-in one is moved on below instead, never to /login.
@@ -132,6 +135,7 @@ export function RegisterPage() {
132135
}
133136

134137
const loginUrl = redirect ? `/login?redirect=${encodeURIComponent(redirect)}` : '/login';
138+
const invitationCopy = invitationRedirect ? invitationArrivalCopy('register', invitationPreview, t) : null;
135139

136140
// Registration here is by invitation only. Say so BEFORE the form; the
137141
// sentence is the `SELF_REGISTRATION_CLOSED` refusal's own copy, the same
@@ -226,13 +230,11 @@ export function RegisterPage() {
226230
onVerificationRequired={(email) => setPendingEmail(email)}
227231
loginUrl={loginUrl}
228232
// #25886 — an invitee is told to register the invited address: the
229-
// invitation is accepted only by the account that carries it.
230-
title={invitationRedirect ? t('auth.register.invitationTitle') : t('auth.register.title')}
231-
description={
232-
invitationRedirect
233-
? t('auth.register.invitationDescription')
234-
: t('auth.register.description')
235-
}
233+
// invitation is accepted only by the account that carries it. #26473 —
234+
// with the preview, the card names the inviter and the organization,
235+
// and shows the masked address; the email field stays empty.
236+
title={invitationCopy ? invitationCopy.title : t('auth.register.title')}
237+
description={invitationCopy ? invitationCopy.description : t('auth.register.description')}
236238
linkComponent={RouterLink}
237239
errorMessages={signUpRefusalMessages(t)}
238240
labels={{

0 commit comments

Comments
 (0)