Skip to content

Commit 3ffbe1f

Browse files
authored
fix(ui): remove back button from sign-in password compromised/pwned error screen (#8280)
1 parent 30ec271 commit 3ffbe1f

3 files changed

Lines changed: 9 additions & 52 deletions

File tree

.changeset/pink-taxes-do.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@clerk/ui': patch
3+
---
4+
5+
Remove back button on the sign-in password compromised/pwned error screen.
6+
7+
These errors are not recoverable by re-entering the password, so the back button led to a confusing dead end that would always take you back to the same error.

packages/ui/src/components/SignIn/SignInFactorOne.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,8 @@ function SignInFactorOneInternal(): JSX.Element {
155155
}
156156

157157
if (showAllStrategies || showForgotPasswordStrategies) {
158-
const canGoBack = factorHasLocalStrategy(currentFactor);
158+
// Password errors are not recoverable by re-entering the password, so we hide the back button
159+
const canGoBack = factorHasLocalStrategy(currentFactor) && !passwordErrorCode;
159160

160161
const toggle = showAllStrategies ? toggleAllStrategies : toggleForgotPasswordStrategies;
161162
const backHandler = () => {

packages/ui/src/components/SignIn/__tests__/SignInFactorOne.test.tsx

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -303,57 +303,6 @@ describe('SignInFactorOne', () => {
303303
await screen.findByText('First, enter the code sent to your phone');
304304
});
305305

306-
it('entering a pwned password, then going back and clicking forgot password should result in the correct title', async () => {
307-
const { wrapper, fixtures } = await createFixtures(f => {
308-
f.withEmailAddress();
309-
f.withPassword();
310-
f.withPreferredSignInStrategy({ strategy: 'password' });
311-
f.startSignInWithEmailAddress({
312-
supportPassword: true,
313-
supportEmailCode: true,
314-
supportResetPassword: true,
315-
});
316-
});
317-
fixtures.signIn.prepareFirstFactor.mockReturnValueOnce(Promise.resolve({} as SignInResource));
318-
319-
const errJSON = {
320-
code: 'form_password_pwned',
321-
long_message:
322-
'Password has been found in an online data breach. For account safety, please reset your password.',
323-
message: 'Password has been found in an online data breach. For account safety, please reset your password.',
324-
meta: { param_name: 'password' },
325-
};
326-
327-
fixtures.signIn.attemptFirstFactor.mockRejectedValueOnce(
328-
new ClerkAPIResponseError('Error', {
329-
data: [errJSON],
330-
status: 422,
331-
}),
332-
);
333-
334-
const { userEvent } = render(<SignInFactorOne />, { wrapper });
335-
await userEvent.type(screen.getByLabelText('Password'), '123456');
336-
await userEvent.click(screen.getByText('Continue'));
337-
338-
await screen.findByText('Password compromised');
339-
await screen.findByText(
340-
'This password has been found as part of a breach and can not be used, please reset your password.',
341-
);
342-
await screen.findByText('Or, sign in with another method');
343-
344-
// Go back
345-
await userEvent.click(screen.getByText('Back'));
346-
347-
// Choose to reset password via "Forgot password" instead
348-
await userEvent.click(screen.getByText(/Forgot password/i));
349-
await screen.findByText('Forgot Password?');
350-
expect(
351-
screen.queryByText(
352-
'This password has been found as part of a breach and can not be used, please reset your password.',
353-
),
354-
).not.toBeInTheDocument();
355-
});
356-
357306
it('using an compromised password should show the compromised password screen', async () => {
358307
const { wrapper, fixtures } = await createFixtures(f => {
359308
f.withEmailAddress();

0 commit comments

Comments
 (0)