Skip to content

Commit 0746279

Browse files
committed
Merge PR 26044 (invitation arrival copy) into the i18n batch
Claude-Session: https://claude.ai/code/session_01FpUtgwNrSiRgWJ8GAepPeP Co-authored-by: Claude <noreply@anthropic.com> # Conflicts: # scripts/sdui-manifest.record.json
2 parents d1355a7 + 5a7ff83 commit 0746279

21 files changed

Lines changed: 403 additions & 22 deletions

File tree

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
'@object-ui/app-shell': patch
3+
'@object-ui/console': patch
4+
'@object-ui/i18n': patch
5+
---
6+
7+
fix(app-shell,console): an invitee who opens the invitation link signed out is greeted for the invitation, offered "Create an account and join" first, and the accept page names the inviter
8+
9+
Clause-②: yes
10+
Metadata-protocol: none
11+
12+
- **Login page.** A signed-out visitor arriving at `/login?redirect=/accept-invitation/ID` used to see the returning-user card ("Welcome back · Sign in to continue your work") with a small "Sign up" link under the form. Both login pages (the console's own and `DefaultLoginPage`) now title the card "Accept your invitation · Use the email address the invitation was sent to." Where the server offers sign-up to this visitor, a full-width "Create an account and join" link (the new `InvitationSignUpPrompt` export) sits above the sign-in form in place of the small link. With sign-up switched off, the visitor gets the invitation header and the sign-in form only.
13+
- **Register page.** From an invitation redirect, both register pages title the form "Create an account to join" and ask for the address the invitation was sent to, because only that account can accept it.
14+
- **Accept page.** `DefaultAcceptInvitationPage` shows an "Invited by" row with the inviting member's email, which `GET /organization/get-invitation` already returns as `inviterEmail`. That route returns no inviter name.
15+
- **Not in this change.** The signed-out pages name no organization, inviter or invited address, and do not prefill the email. The only invitation read the server serves answers a signed-out caller `401`, so a preview for signed-out visitors needs a new server read first.
16+
- New locale keys in all ten packs: `auth.login.invitationTitle`, `auth.login.invitationDescription`, `auth.login.invitationSignUpButton`, `auth.login.invitationSignInDivider`, `auth.register.invitationTitle`, `auth.register.invitationDescription`, `organization.accept.invitedBy`.

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

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@
2626
* (objectui#11806). The sign-in request goes to the same server, so a
2727
* live-looking form would only have deferred that news to the submit.
2828
*
29+
* A visitor who arrived signed out from an invitation link
30+
* (`?redirect=/accept-invitation/ID`) is greeted for that invitation instead
31+
* of as a returning user, and, where sign-up is offered, gets app-shell's
32+
* `InvitationSignUpPrompt` above the form in place of the small "Sign up"
33+
* link — the same prompt `DefaultLoginPage` shows (#25886).
34+
*
2935
* Layout (objectui#12600): one 400 px column — brand mark, the card, a footer.
3036
* The card carries this page's own two-line header, so `<LoginForm>` renders
3137
* with `hideHeader`. On a dev instance the card's last row offers a one-click
@@ -54,6 +60,7 @@ import {
5460
needsBootstrapProbe,
5561
useBootstrapStatus,
5662
LocaleSwitcher,
63+
InvitationSignUpPrompt,
5764
} from '@object-ui/app-shell';
5865
import { AuthLayout } from './AuthLayout';
5966
import { followOauthAuthorize } from './followAuthorize';
@@ -304,6 +311,7 @@ export function LoginPage() {
304311
? `/register?redirect=${encodeURIComponent(redirect)}`
305312
: '/register';
306313
const legalLinks = readLegalLinks(authConfig);
314+
const offerSignUp = configRead === 'known' && signUpOffer === 'form';
307315

308316
return (
309317
<AuthLayout formWidth="base">
@@ -345,18 +353,28 @@ export function LoginPage() {
345353
<>
346354
<div className="mb-5">
347355
<h1 className="text-xl font-semibold tracking-tight text-foreground">
348-
{t('auth.login.welcomeTitle', { defaultValue: 'Welcome back' })}
356+
{invitationRedirect
357+
? t('auth.login.invitationTitle', { defaultValue: 'Accept your invitation' })
358+
: t('auth.login.welcomeTitle', { defaultValue: 'Welcome back' })}
349359
</h1>
350360
<p className="mt-1 text-[13px] text-muted-foreground">
351-
{t('auth.login.welcomeDescription', {
352-
defaultValue: 'Sign in to continue your work',
353-
})}
361+
{invitationRedirect
362+
? t('auth.login.invitationDescription', {
363+
defaultValue: 'Use the email address the invitation was sent to.',
364+
})
365+
: t('auth.login.welcomeDescription', {
366+
defaultValue: 'Sign in to continue your work',
367+
})}
354368
</p>
355369
</div>
370+
{invitationRedirect && offerSignUp ? (
371+
<div className="mb-5">
372+
<InvitationSignUpPrompt registerUrl={registerUrl} />
373+
</div>
374+
) : null}
356375
<LoginFormCard
357-
registerUrl={
358-
configRead === 'known' && signUpOffer === 'form' ? registerUrl : undefined
359-
}
376+
// An invitee's sign-up is the prompt above, not a second link.
377+
registerUrl={offerSignUp && !invitationRedirect ? registerUrl : undefined}
360378
redirect={redirect}
361379
/>
362380
{devSeedAdmin ? <DevAdminRow seed={devSeedAdmin} /> : null}

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

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -257,10 +257,23 @@ export function RegisterPage() {
257257
<AuthLayout formWidth="md">
258258
<Card className="border-border/60 px-4 py-8 shadow-sm shadow-primary/5 backdrop-blur supports-[backdrop-filter]:bg-card/95">
259259
<RegisterForm
260-
title={t('auth.register.title', { defaultValue: 'Create an account' })}
261-
description={t('auth.register.description', {
262-
defaultValue: 'Create your account to start building.',
263-
})}
260+
// #25886 — an invitee is told to register the invited address: the
261+
// invitation is accepted only by the account that carries it.
262+
title={
263+
invitationRedirect
264+
? t('auth.register.invitationTitle', { defaultValue: 'Create an account to join' })
265+
: t('auth.register.title', { defaultValue: 'Create an account' })
266+
}
267+
description={
268+
invitationRedirect
269+
? t('auth.register.invitationDescription', {
270+
defaultValue:
271+
'Register with the email address the invitation was sent to. The invitation can only be accepted with that address.',
272+
})
273+
: t('auth.register.description', {
274+
defaultValue: 'Create your account to start building.',
275+
})
276+
}
264277
loginUrl={loginUrl}
265278
verificationCallbackURL={verificationCallbackURL}
266279
linkComponent={RouterLink}

‎ui/apps/console/src/pages/auth/__tests__/signUpFollowsPosture-11691.test.tsx‎

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ import { RegisterPage } from '../RegisterPage';
4949

5050
const AUTH_URL = 'http://localhost/api/v1/auth';
5151
const SIGN_UP_LINK = { name: 'Sign up' } as const;
52+
/** #25886 — an invitee's sign-up is the register-first prompt, not the small link. */
53+
const INVITE_SIGN_UP = { name: builtInLocales.en.auth.login.invitationSignUpButton } as const;
5254
const INVITATION = '/accept-invitation/inv_1';
5355
const INVITE_QUERY = `?redirect=${encodeURIComponent(INVITATION)}`;
5456
const SELF_REGISTRATION_CLOSED_TEXT = builtInLocales.en.auth.register.errors.selfRegistrationClosed;
@@ -162,11 +164,20 @@ describe('LoginPage — the "Sign up" link follows the audience posture (objectu
162164
expect(screen.queryByRole('link', SIGN_UP_LINK)).toBeNull();
163165
});
164166

165-
it('under invite_only, still offers "Sign up" to an invitation redirect, carrying the redirect', async () => {
167+
it('under invite_only, still offers sign-up to an invitation redirect, carrying the redirect', async () => {
166168
renderAt(`/login${INVITE_QUERY}`, configFor('invite_only'));
167169
await loginConfigApplied();
168170

169-
expect(screen.getByRole('link', SIGN_UP_LINK).getAttribute('href')).toBe(`/register${INVITE_QUERY}`);
171+
// #25886 — greeted for the invitation, not as a returning user, with the
172+
// register-first prompt in place of the small link, never both.
173+
expect(
174+
screen.getByRole('heading', { name: builtInLocales.en.auth.login.invitationTitle }),
175+
).toBeInTheDocument();
176+
expect(
177+
screen.queryByRole('heading', { name: builtInLocales.en.auth.login.welcomeTitle }),
178+
).toBeNull();
179+
expect(screen.getByRole('link', INVITE_SIGN_UP).getAttribute('href')).toBe(`/register${INVITE_QUERY}`);
180+
expect(screen.queryByRole('link', SIGN_UP_LINK)).toBeNull();
170181
expect(wire.bootstrapProbes).toBe(0);
171182
});
172183

@@ -202,6 +213,11 @@ describe('LoginPage — the "Sign up" link follows the audience posture (objectu
202213
await loginConfigApplied();
203214

204215
expect(screen.queryByRole('link', SIGN_UP_LINK)).toBeNull();
216+
// #25886 — still greeted for the invitation, but offered no registration.
217+
expect(
218+
screen.getByRole('heading', { name: builtInLocales.en.auth.login.invitationTitle }),
219+
).toBeInTheDocument();
220+
expect(screen.queryByRole('link', INVITE_SIGN_UP)).toBeNull();
205221
});
206222
});
207223

@@ -220,9 +236,13 @@ describe('RegisterPage — explains invitation-only registration before the form
220236
it('an invitation redirect reaches a working registration under invite_only, from /login on', async () => {
221237
renderAt(`/login${INVITE_QUERY}`, configFor('invite_only'));
222238
await loginConfigApplied();
223-
await userEvent.click(screen.getByRole('link', SIGN_UP_LINK));
239+
await userEvent.click(screen.getByRole('link', INVITE_SIGN_UP));
224240

225241
await userEvent.type(await screen.findByLabelText('Name'), 'Ada');
242+
// #25886 — the form asks for the invited address.
243+
expect(
244+
screen.getByRole('heading', { name: builtInLocales.en.auth.register.invitationTitle }),
245+
).toBeInTheDocument();
226246
await userEvent.type(screen.getByLabelText('Email'), 'ada@example.com');
227247
await userEvent.type(screen.getByLabelText('Password'), 'hunter2hunter2');
228248
await userEvent.type(screen.getByLabelText('Confirm Password'), 'hunter2hunter2');

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

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@
1414
* Retry that reads it again, in place of the form (objectui#11806). The
1515
* sign-in request goes to the same server, so a live-looking form would only
1616
* have deferred that news to the submit.
17+
*
18+
* A visitor who arrived from an invitation link (`?redirect=/accept-invitation/ID`)
19+
* is greeted for that invitation instead of as a returning user, and, where
20+
* sign-up is offered, gets `InvitationSignUpPrompt` (`./invitationArrival`)
21+
* above the form in place of the small "Sign up" link (#25886). The console's
22+
* own login page does the same.
1723
*/
1824

1925
import { useEffect, useState } from 'react';
@@ -33,6 +39,7 @@ import { AuthPageLayout } from './AuthPageLayout.js';
3339
import { signInRefusalMessages } from './signInRefusalMessages.js';
3440
import { decideSignUpOffer, isInvitationRedirect, needsBootstrapProbe } from './signUpOffer.js';
3541
import { useBootstrapStatus } from './bootstrapStatus.js';
42+
import { InvitationSignUpPrompt } from './invitationArrival.js';
3643

3744
const RouterLink = ({ href, className, children }: AuthLinkComponentProps) => (
3845
<Link to={href} className={className}>{children}</Link>
@@ -121,6 +128,11 @@ export function LoginPage() {
121128
? `/register?redirect=${encodeURIComponent(redirect)}`
122129
: '/register';
123130

131+
const offerSignUp = configRead === 'known' && signUpOffer === 'form';
132+
// #25886 — an invitee is greeted for the invitation, and offered the
133+
// register-first prompt in place of `LoginForm`'s own small link.
134+
const invitationSignUpUrl = invitationRedirect && offerSignUp ? registerUrl : undefined;
135+
124136
if (serverUnreachable) {
125137
return (
126138
<AuthPageLayout>
@@ -129,14 +141,15 @@ export function LoginPage() {
129141
);
130142
}
131143

132-
return (
133-
<AuthPageLayout>
144+
const form = (
134145
<LoginForm
135146
onSuccess={() => navigate('/')}
136-
registerUrl={configRead === 'known' && signUpOffer === 'form' ? registerUrl : undefined}
147+
registerUrl={offerSignUp && !invitationRedirect ? registerUrl : undefined}
137148
forgotPasswordUrl="/forgot-password"
138149
title={t('auth.login.title')}
139150
description={t('auth.login.description')}
151+
// An invitee's header is drawn above the prompt, below.
152+
hideHeader={invitationRedirect}
140153
linkComponent={RouterLink}
141154
errorMessages={signInRefusalMessages(t)}
142155
labels={{
@@ -178,6 +191,23 @@ export function LoginPage() {
178191
backToSsoText: t('auth.login.backToSsoText'),
179192
}}
180193
/>
194+
);
195+
196+
if (!invitationRedirect) return <AuthPageLayout>{form}</AuthPageLayout>;
197+
198+
return (
199+
<AuthPageLayout>
200+
<div
201+
data-testid="login-invitation-arrival"
202+
className="mx-auto flex w-full flex-col justify-center space-y-6 sm:max-w-[400px]"
203+
>
204+
<AuthFormHeader
205+
title={t('auth.login.invitationTitle')}
206+
description={t('auth.login.invitationDescription')}
207+
/>
208+
{invitationSignUpUrl ? <InvitationSignUpPrompt registerUrl={invitationSignUpUrl} /> : null}
209+
{form}
210+
</div>
181211
</AuthPageLayout>
182212
);
183213
}

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,14 @@ export function RegisterPage() {
225225
onSuccess={() => navigate('/')}
226226
onVerificationRequired={(email) => setPendingEmail(email)}
227227
loginUrl={loginUrl}
228-
title={t('auth.register.title')}
229-
description={t('auth.register.description')}
228+
// #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+
}
230236
linkComponent={RouterLink}
231237
errorMessages={signUpRefusalMessages(t)}
232238
labels={{

‎ui/packages/app-shell/src/console/auth/__tests__/defaultPagesFollowPosture-11705.test.tsx‎

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ import { RegisterPage } from '../RegisterPage';
5151
const AUTH_URL = 'http://localhost/api/v1/auth';
5252
const en = builtInLocales.en.auth;
5353
const SIGN_UP_LINK = { name: en.login.signUpText } as const;
54+
/** #25886 — an invitee's sign-up is the register-first prompt, not the small link. */
55+
const INVITE_SIGN_UP = { name: en.login.invitationSignUpButton } as const;
5456
const CREATE_ACCOUNT = { name: en.register.submitButton } as const;
5557
const INVITATION = '/accept-invitation/inv_1';
5658
const INVITE_QUERY = `?redirect=${encodeURIComponent(INVITATION)}`;
@@ -167,11 +169,16 @@ describe('DefaultLoginPage — the "Sign up" link follows the audience posture (
167169
expect(screen.queryByRole('link', SIGN_UP_LINK)).toBeNull();
168170
});
169171

170-
it('under invite_only, still offers "Sign up" to an invitation redirect, carrying the redirect', async () => {
172+
it('under invite_only, still offers sign-up to an invitation redirect, carrying the redirect', async () => {
171173
renderAt(`/login${INVITE_QUERY}`, configFor('invite_only'));
172174
await loginConfigApplied();
173175

174-
expect(screen.getByRole('link', SIGN_UP_LINK).getAttribute('href')).toBe(`/register${INVITE_QUERY}`);
176+
// #25886 — greeted for the invitation, with the register-first prompt in
177+
// place of the small link, never both.
178+
expect(screen.getByRole('heading', { name: en.login.invitationTitle })).toBeInTheDocument();
179+
expect(screen.queryByRole('heading', { name: en.login.title })).toBeNull();
180+
expect(screen.getByRole('link', INVITE_SIGN_UP).getAttribute('href')).toBe(`/register${INVITE_QUERY}`);
181+
expect(screen.queryByRole('link', SIGN_UP_LINK)).toBeNull();
175182
expect(wire.bootstrapProbes).toBe(0);
176183
});
177184

@@ -207,6 +214,9 @@ describe('DefaultLoginPage — the "Sign up" link follows the audience posture (
207214
await loginConfigApplied();
208215

209216
expect(screen.queryByRole('link', SIGN_UP_LINK)).toBeNull();
217+
// #25886 — still greeted for the invitation, but offered no registration.
218+
expect(screen.getByRole('heading', { name: en.login.invitationTitle })).toBeInTheDocument();
219+
expect(screen.queryByRole('link', INVITE_SIGN_UP)).toBeNull();
210220
expect(wire.bootstrapProbes).toBe(0);
211221
});
212222
});
@@ -227,9 +237,12 @@ describe('DefaultRegisterPage — explains invitation-only registration before t
227237
it('an invitation redirect reaches a working registration under invite_only, from /login on', async () => {
228238
renderAt(`/login${INVITE_QUERY}`, configFor('invite_only'));
229239
await loginConfigApplied();
230-
await userEvent.click(screen.getByRole('link', SIGN_UP_LINK));
240+
await userEvent.click(screen.getByRole('link', INVITE_SIGN_UP));
231241

232242
await userEvent.type(await screen.findByLabelText(en.register.nameLabel), 'Ada');
243+
// #25886 — the form asks for the invited address.
244+
expect(screen.getByRole('heading', { name: en.register.invitationTitle })).toBeInTheDocument();
245+
expect(screen.getByText(en.register.invitationDescription)).toBeInTheDocument();
233246
await userEvent.type(screen.getByLabelText(en.register.emailLabel), 'ada@example.com');
234247
await userEvent.type(screen.getByLabelText(en.register.passwordLabel), 'hunter2hunter2');
235248
await userEvent.type(screen.getByLabelText(en.register.confirmPasswordLabel), 'hunter2hunter2');
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/**
2+
* ObjectUI
3+
* Copyright (c) 2024-present ObjectStack Inc.
4+
*
5+
* This source code is licensed under the MIT license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
*/
8+
9+
/**
10+
* invitationArrival — the register-first action a login page shows a visitor
11+
* who arrived signed out from an invitation link (#25886).
12+
*
13+
* `DefaultAcceptInvitationPage` bounces a signed-out visitor to
14+
* `/login?redirect=/accept-invitation/ID` (`isInvitationRedirect` in
15+
* `./signUpOffer`). Most invitees have never had an account here, so for them
16+
* the generic "Welcome back" card with a small "Sign up" link under the form
17+
* read as the wrong site. Both login pages — the console's own
18+
* (`apps/console/src/pages/auth/LoginPage.tsx`) and this package's
19+
* `DefaultLoginPage` — retitle the card for that visitor and render this
20+
* prompt above the form in place of the small link, so there is ONE prompt and
21+
* no second copy of it.
22+
*
23+
* The prompt names no organization and no inviter: the only invitation read
24+
* the server serves (`GET /organization/get-invitation`) answers a signed-out
25+
* caller `401`, and an anonymous preview is a server decision this package
26+
* does not make. It is rendered only when the page's sign-up offer is `form`,
27+
* so a server with sign-up switched off is never offered a registration it
28+
* refuses.
29+
*/
30+
31+
import { Link } from 'react-router-dom';
32+
import { useObjectTranslation } from '@object-ui/i18n';
33+
34+
/** A full-width outlined link with the auth primary button's box. */
35+
const INVITATION_SIGN_UP_CLASS =
36+
'inline-flex h-10 w-full items-center justify-center gap-2 rounded-lg border border-primary/40 bg-primary/5 px-4 py-2 text-sm font-medium text-primary shadow-sm transition-colors hover:bg-primary/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary/40 focus-visible:ring-offset-2';
37+
38+
/**
39+
* "Create an account and join", then a divider that hands over to the sign-in
40+
* form below it. `registerUrl` is the page's own `/register?redirect=…`, so the
41+
* invitation survives the hop.
42+
*/
43+
export function InvitationSignUpPrompt({ registerUrl }: { registerUrl: string }) {
44+
const { t } = useObjectTranslation();
45+
return (
46+
<div data-testid="invitation-sign-up" className="flex flex-col gap-4">
47+
<Link to={registerUrl} className={INVITATION_SIGN_UP_CLASS}>
48+
{t('auth.login.invitationSignUpButton', { defaultValue: 'Create an account and join' })}
49+
</Link>
50+
<div className="flex items-center gap-3 text-xs text-muted-foreground">
51+
<span aria-hidden="true" className="h-px flex-1 bg-border" />
52+
<span>
53+
{t('auth.login.invitationSignInDivider', {
54+
defaultValue: 'or sign in to an existing account',
55+
})}
56+
</span>
57+
<span aria-hidden="true" className="h-px flex-1 bg-border" />
58+
</div>
59+
</div>
60+
);
61+
}

0 commit comments

Comments
 (0)