Skip to content

Commit 7dfe799

Browse files
feat(mosaic): show the compromised password message as an error and hold pending on sign-in notices
1 parent 82f10bd commit 7dfe799

7 files changed

Lines changed: 32 additions & 7 deletions

File tree

‎packages/mosaic/src/features/sign-in/sign-in.messages.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export const signInMessages = {
4343
},
4444
passwordCompromised: {
4545
title: 'Password compromised',
46-
description: 'This password has been found as part of a breach and can not be used, please reset your password.',
46+
message: 'This password has been found as part of a breach and can not be used, please reset your password.',
4747
resetPassword: 'Reset your password',
4848
},
4949
emailLink: {

‎packages/mosaic/src/features/sign-in/steps/notice-step.tsx‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ export function NoticeStep({
8989
<SignInPasswordCompromised
9090
focusRef={focusRef}
9191
globalErrorMessage={globalErrorMessage}
92+
isPending={isPending}
9293
onForgotPassword={onForgotPassword}
9394
onCancel={onCancel}
9495
/>
@@ -100,6 +101,7 @@ export function NoticeStep({
100101
identifier={step.identifier}
101102
onEditIdentifier={onEditIdentifier}
102103
globalErrorMessage={globalErrorMessage}
104+
isPending={isPending}
103105
resend={resend}
104106
onCancel={onCancel}
105107
/>

‎packages/mosaic/src/features/sign-in/steps/sign-in-email-link.tsx‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ interface SignInEmailLinkProps {
1212
identifier: string;
1313
onEditIdentifier?: () => void;
1414
globalErrorMessage?: string;
15+
isPending: boolean;
1516
resend?: VerificationCodeResend;
1617
onCancel?: () => void;
1718
focusRef?: Ref<HTMLElement>;
@@ -21,6 +22,7 @@ export function SignInEmailLink({
2122
identifier,
2223
onEditIdentifier,
2324
globalErrorMessage,
25+
isPending,
2426
resend,
2527
onCancel,
2628
focusRef,
@@ -36,6 +38,7 @@ export function SignInEmailLink({
3638
<SignInIdentityPreview
3739
identifier={identifier}
3840
editLabel={m.password.editIdentifier}
41+
disabled={isPending}
3942
onEdit={onEditIdentifier}
4043
/>
4144
{resend ? (
@@ -47,7 +50,7 @@ export function SignInEmailLink({
4750
size='sm'
4851
color='neutral'
4952
variant='link'
50-
disabled={resend.disabled}
53+
disabled={resend.disabled || isPending}
5154
onClick={resend.onClick}
5255
>
5356
{resend.label}
@@ -68,6 +71,7 @@ export function SignInEmailLink({
6871
type='button'
6972
variant='outline'
7073
color='neutral'
74+
disabled={isPending}
7175
onClick={onCancel}
7276
>
7377
{m.useAnotherMethod}

‎packages/mosaic/src/features/sign-in/steps/sign-in-password-compromised.tsx‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
11
import { useMergeRefs } from '@floating-ui/react';
22
import type { Ref } from 'react';
33

4-
import { Button } from '../../../components/button';
4+
import { Button, SubmitButton } from '../../../components/button';
55
import { Card } from '../../../components/card';
66
import { useFlowAutoFocus } from '../../../components/flow';
77
import { useMessages } from '../../../localization';
88

99
interface SignInPasswordCompromisedProps {
1010
globalErrorMessage?: string;
11+
isPending: boolean;
1112
onForgotPassword?: () => void;
1213
onCancel?: () => void;
1314
focusRef?: Ref<HTMLElement>;
1415
}
1516

1617
export function SignInPasswordCompromised({
1718
globalErrorMessage,
19+
isPending,
1820
onForgotPassword,
1921
onCancel,
2022
focusRef,
@@ -26,13 +28,12 @@ export function SignInPasswordCompromised({
2628
<>
2729
<Card.Header>
2830
<Card.Title>{m.passwordCompromised.title}</Card.Title>
29-
<Card.Description>{m.passwordCompromised.description}</Card.Description>
3031
</Card.Header>
3132
<Card.Banner
3233
role='alert'
3334
color='negative'
3435
>
35-
{globalErrorMessage}
36+
{globalErrorMessage ?? m.passwordCompromised.message}
3637
</Card.Banner>
3738
<Card.Footer>
3839
{onCancel ? (
@@ -41,19 +42,22 @@ export function SignInPasswordCompromised({
4142
type='button'
4243
variant='outline'
4344
color='neutral'
45+
disabled={isPending}
4446
onClick={onCancel}
4547
>
4648
{m.useAnotherMethod}
4749
</Button>
4850
) : null}
4951
{onForgotPassword ? (
50-
<Button
52+
<SubmitButton
5153
ref={ref}
5254
type='button'
55+
isPending={isPending}
56+
pendingLabel={m.forgotPassword.pending}
5357
onClick={onForgotPassword}
5458
>
5559
{m.passwordCompromised.resetPassword}
56-
</Button>
60+
</SubmitButton>
5761
) : null}
5862
</Card.Footer>
5963
</>

‎packages/swingset/src/lib/registry.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,7 @@ import {
371371
NoticeLocked as SignInNoticeLocked,
372372
NoticeNoMethods as SignInNoticeNoMethods,
373373
NoticePasswordCompromised as SignInNoticePasswordCompromised,
374+
NoticePasswordCompromisedPending as SignInNoticePasswordCompromisedPending,
374375
SignUpDetails as SignInSignUpDetails,
375376
} from '../stories/sign-in.stories';
376377
import {
@@ -1301,6 +1302,7 @@ const signInModule: StoryModule = {
13011302
NoticeNoMethods: SignInNoticeNoMethods,
13021303
NoticeActionBlocked: SignInNoticeActionBlocked,
13031304
NoticePasswordCompromised: SignInNoticePasswordCompromised,
1305+
NoticePasswordCompromisedPending: SignInNoticePasswordCompromisedPending,
13041306
NoticeEmailLinkSent: SignInNoticeEmailLinkSent,
13051307
NewPasswordReset: SignInNewPasswordReset,
13061308
SignUpDetails: SignInSignUpDetails,

‎packages/swingset/src/stories/sign-in.mdx‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,10 @@ Each section is one component in `features/sign-in/steps/`, and each example und
244244

245245
<Story name='NoticePasswordCompromised' storyModule={Stories} />
246246

247+
#### Password compromised pending
248+
249+
<Story name='NoticePasswordCompromisedPending' storyModule={Stories} />
250+
247251
#### Email link sent
248252

249253
<Story name='NoticeEmailLinkSent' storyModule={Stories} />

‎packages/swingset/src/stories/sign-in.stories.tsx‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,15 @@ export function NoticePasswordCompromised() {
662662
return <StepPanel step={{ kind: 'notice', purpose: 'password-compromised' }} />;
663663
}
664664

665+
export function NoticePasswordCompromisedPending() {
666+
return (
667+
<StepPanel
668+
step={{ kind: 'notice', purpose: 'password-compromised' }}
669+
isPending
670+
/>
671+
);
672+
}
673+
665674
export function NoticeEmailLinkSent() {
666675
return <StepPanel step={{ kind: 'notice', purpose: 'email-link', identifier: IDENTIFIER }} />;
667676
}

0 commit comments

Comments
 (0)