Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(clerk-js,localizations): Nav to reset-password if needs_new_password #2984

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changeset/four-ties-yawn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'@clerk/localizations': minor
'@clerk/clerk-js': minor
---

During sign in, navigate to the `reset-password` route if the user needs a new password. This happens when you enforce password usage during sign-in in your dashboard. Previously this case wasn't handled in the password form.

The `signIn.resetPassword.requiredMessage` localization was updated to `'For security reasons, it is required to reset your password.'`.
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ export const SignInFactorOnePasswordCard = (props: SignInFactorOnePasswordProps)
return setActive({ session: res.createdSessionId, beforeEmit: navigateAfterSignIn });
case 'needs_second_factor':
return navigate('../factor-two');
case 'needs_new_password':
return navigate('../reset-password');
default:
return console.error(clerkInvalidFAPIResponse(res.status, supportEmail));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ describe('ResetPassword', () => {
} as SignInResource);
const { userEvent } = render(<ResetPassword />, { wrapper });

expect(screen.queryByText(/account already exists/i)).toBeInTheDocument();
expect(screen.queryByText('For security reasons, it is required to reset your password.')).toBeInTheDocument();
expect(screen.queryByRole('checkbox', { name: /sign out of all other devices/i })).not.toBeInTheDocument();
await userEvent.type(screen.getByLabelText(/New password/i), 'testtest');
await userEvent.type(screen.getByLabelText(/Confirm password/i), 'testtest');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,29 @@ describe('SignInFactorOne', () => {
});
});
});

it('redirects to `reset-password` if signIn requires a new password', async () => {
const { wrapper, fixtures } = await createFixtures(f => {
f.withEmailAddress();
f.withPassword();
f.withPreferredSignInStrategy({ strategy: 'password' });
f.startSignInWithPhoneNumber({ supportPassword: true });
});
fixtures.signIn.prepareFirstFactor.mockReturnValueOnce(Promise.resolve({} as SignInResource));

fixtures.signIn.attemptFirstFactor.mockReturnValueOnce(
Promise.resolve({ status: 'needs_new_password' } as SignInResource),
);

await runFakeTimers(async () => {
const { userEvent } = render(<SignInFactorOne />, { wrapper });
await userEvent.type(screen.getByLabelText('Password'), '123456');
await userEvent.click(screen.getByText('Continue'));
await waitFor(() => {
expect(fixtures.router.navigate).toHaveBeenCalledWith('../reset-password');
});
});
});
});

describe('Forgot Password', () => {
Expand Down
3 changes: 1 addition & 2 deletions packages/localizations/src/cs-CZ.ts
Original file line number Diff line number Diff line change
Expand Up @@ -370,8 +370,7 @@ export const csCZ: LocalizationResource = {
},
resetPassword: {
formButtonPrimary: 'Obnovit heslo',
requiredMessage:
'An account already exists with an unverified email address. Please reset your password for security.',
requiredMessage: 'For security reasons, it is required to reset your password.',
successMessage: 'Vaše heslo bylo úspěšně změněno. Přihlašuji vás, prosím počkejte okamžik.',
title: 'Obnovit heslo',
},
Expand Down
3 changes: 1 addition & 2 deletions packages/localizations/src/da-DK.ts
Original file line number Diff line number Diff line change
Expand Up @@ -371,8 +371,7 @@ export const daDK: LocalizationResource = {
},
resetPassword: {
formButtonPrimary: 'Reset Password',
requiredMessage:
'An account already exists with an unverified email address. Please reset your password for security.',
requiredMessage: 'For security reasons, it is required to reset your password.',
successMessage: 'Your password was successfully changed. Signing you in, please wait a moment.',
title: 'Set new password',
},
Expand Down
3 changes: 1 addition & 2 deletions packages/localizations/src/en-US.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,8 +360,7 @@ export const enUS: LocalizationResource = {
},
resetPassword: {
formButtonPrimary: 'Reset Password',
requiredMessage:
'An account already exists with an unverified email address. Please reset your password for security.',
requiredMessage: 'For security reasons, it is required to reset your password.',
successMessage: 'Your password was successfully changed. Signing you in, please wait a moment.',
title: 'Set new password',
},
Expand Down
3 changes: 1 addition & 2 deletions packages/localizations/src/es-ES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -372,8 +372,7 @@ export const esES: LocalizationResource = {
},
resetPassword: {
formButtonPrimary: 'Reset Password',
requiredMessage:
'An account already exists with an unverified email address. Please reset your password for security.',
requiredMessage: 'For security reasons, it is required to reset your password.',
successMessage: 'Your password was successfully changed. Signing you in, please wait a moment.',
title: 'Set new password',
},
Expand Down
3 changes: 1 addition & 2 deletions packages/localizations/src/es-MX.ts
Original file line number Diff line number Diff line change
Expand Up @@ -372,8 +372,7 @@ export const esMX: LocalizationResource = {
},
resetPassword: {
formButtonPrimary: 'Reset Password',
requiredMessage:
'An account already exists with an unverified email address. Please reset your password for security.',
requiredMessage: 'For security reasons, it is required to reset your password.',
successMessage: 'Your password was successfully changed. Signing you in, please wait a moment.',
title: 'Set new password',
},
Expand Down
3 changes: 1 addition & 2 deletions packages/localizations/src/fr-FR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -372,8 +372,7 @@ export const frFR: LocalizationResource = {
},
resetPassword: {
formButtonPrimary: 'Réinitialiser',
requiredMessage:
'An account already exists with an unverified email address. Please reset your password for security.',
requiredMessage: 'For security reasons, it is required to reset your password.',
successMessage:
'Votre mot de passe a été modifié avec succès. Nous vous reconnectons, veuillez patienter un instant.',
title: 'Réinitialiser le mot de passe',
Expand Down
3 changes: 1 addition & 2 deletions packages/localizations/src/he-IL.ts
Original file line number Diff line number Diff line change
Expand Up @@ -368,8 +368,7 @@ export const heIL: LocalizationResource = {
},
resetPassword: {
formButtonPrimary: 'אפס סיסמה',
requiredMessage:
'An account already exists with an unverified email address. Please reset your password for security.',
requiredMessage: 'For security reasons, it is required to reset your password.',
successMessage: 'הסיסמה שלך שונתה בהצלחה. מחבר אותך, אנא המתן רגע.',
title: 'אפס סיסמה',
},
Expand Down
3 changes: 1 addition & 2 deletions packages/localizations/src/it-IT.ts
Original file line number Diff line number Diff line change
Expand Up @@ -371,8 +371,7 @@ export const itIT: LocalizationResource = {
},
resetPassword: {
formButtonPrimary: 'Reset Password',
requiredMessage:
'An account already exists with an unverified email address. Please reset your password for security.',
requiredMessage: 'For security reasons, it is required to reset your password.',
successMessage: 'Your password was successfully changed. Signing you in, please wait a moment.',
title: 'Set new password',
},
Expand Down
3 changes: 1 addition & 2 deletions packages/localizations/src/ko-KR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -368,8 +368,7 @@ export const koKR: LocalizationResource = {
},
resetPassword: {
formButtonPrimary: '비밀번호 재설정',
requiredMessage:
'An account already exists with an unverified email address. Please reset your password for security.',
requiredMessage: 'For security reasons, it is required to reset your password.',
successMessage: '비밀번호가 성공적으로 변경되었습니다. 로그인하는 중입니다. 잠시만 기다려주세요.',
title: '비밀번호 재설정',
},
Expand Down
3 changes: 1 addition & 2 deletions packages/localizations/src/nl-NL.ts
Original file line number Diff line number Diff line change
Expand Up @@ -371,8 +371,7 @@ export const nlNL: LocalizationResource = {
},
resetPassword: {
formButtonPrimary: 'Reset Password',
requiredMessage:
'An account already exists with an unverified email address. Please reset your password for security.',
requiredMessage: 'For security reasons, it is required to reset your password.',
successMessage: 'Your password was successfully changed. Signing you in, please wait a moment.',
title: 'Set new password',
},
Expand Down
3 changes: 1 addition & 2 deletions packages/localizations/src/pl-PL.ts
Original file line number Diff line number Diff line change
Expand Up @@ -371,8 +371,7 @@ export const plPL: LocalizationResource = {
},
resetPassword: {
formButtonPrimary: 'Reset Password',
requiredMessage:
'An account already exists with an unverified email address. Please reset your password for security.',
requiredMessage: 'For security reasons, it is required to reset your password.',
successMessage: 'Your password was successfully changed. Signing you in, please wait a moment.',
title: 'Set new password',
},
Expand Down
3 changes: 1 addition & 2 deletions packages/localizations/src/pt-BR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -371,8 +371,7 @@ export const ptBR: LocalizationResource = {
},
resetPassword: {
formButtonPrimary: 'Redefinir Senha',
requiredMessage:
'An account already exists with an unverified email address. Please reset your password for security.',
requiredMessage: 'For security reasons, it is required to reset your password.',
successMessage: 'Sua senha foi alterada com sucesso. Entrando, por favor aguarde um momento.',
title: 'Redefinir Senha',
},
Expand Down
3 changes: 1 addition & 2 deletions packages/localizations/src/pt-PT.ts
Original file line number Diff line number Diff line change
Expand Up @@ -371,8 +371,7 @@ export const ptPT: LocalizationResource = {
},
resetPassword: {
formButtonPrimary: 'Repor Palavra-passe',
requiredMessage:
'An account already exists with an unverified email address. Please reset your password for security.',
requiredMessage: 'For security reasons, it is required to reset your password.',
successMessage: 'A sua palavra-passe foi alterada com sucesso. Entrando, por favor aguarde um momento.',
title: 'Repor Palavra-passe',
},
Expand Down
3 changes: 1 addition & 2 deletions packages/localizations/src/ru-RU.ts
Original file line number Diff line number Diff line change
Expand Up @@ -375,8 +375,7 @@ export const ruRU: LocalizationResource = {
},
resetPassword: {
formButtonPrimary: 'Сбросить пароль',
requiredMessage:
'An account already exists with an unverified email address. Please reset your password for security.',
requiredMessage: 'For security reasons, it is required to reset your password.',
successMessage: 'Ваш пароль успешно изменен. Выполняется вход, подождите.',
title: 'Сбросить пароль',
},
Expand Down
3 changes: 1 addition & 2 deletions packages/localizations/src/sk-SK.ts
Original file line number Diff line number Diff line change
Expand Up @@ -371,8 +371,7 @@ export const skSK: LocalizationResource = {
},
resetPassword: {
formButtonPrimary: 'Obnoviť heslo',
requiredMessage:
'An account already exists with an unverified email address. Please reset your password for security.',
requiredMessage: 'For security reasons, it is required to reset your password.',
successMessage: 'Vaše heslo bolo úspešne zmenené. Prihlasujem vás, prosím počkajte okamžite.',
title: 'Obnoviť heslo',
},
Expand Down
3 changes: 1 addition & 2 deletions packages/localizations/src/sv-SE.ts
Original file line number Diff line number Diff line change
Expand Up @@ -371,8 +371,7 @@ export const svSE: LocalizationResource = {
},
resetPassword: {
formButtonPrimary: 'Reset Password',
requiredMessage:
'An account already exists with an unverified email address. Please reset your password for security.',
requiredMessage: 'For security reasons, it is required to reset your password.',
successMessage: 'Your password was successfully changed. Signing you in, please wait a moment.',
title: 'Set new password',
},
Expand Down
3 changes: 1 addition & 2 deletions packages/localizations/src/tr-TR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -371,8 +371,7 @@ export const trTR: LocalizationResource = {
},
resetPassword: {
formButtonPrimary: 'Şifremi sıfırla',
requiredMessage:
'An account already exists with an unverified email address. Please reset your password for security.',
requiredMessage: 'For security reasons, it is required to reset your password.',
successMessage: 'Şifreniz başarıyla sıfırlandı. Oturumunuz açılıyor...',
title: 'Şifre sıfırlama',
},
Expand Down
3 changes: 1 addition & 2 deletions packages/localizations/src/uk-UA.ts
Original file line number Diff line number Diff line change
Expand Up @@ -371,8 +371,7 @@ export const ukUA: LocalizationResource = {
},
resetPassword: {
formButtonPrimary: 'Скинути пароль',
requiredMessage:
'An account already exists with an unverified email address. Please reset your password for security.',
requiredMessage: 'For security reasons, it is required to reset your password.',
successMessage: 'Ваш пароль успішно змінено. Виконується вхід, зачекайте.',
title: 'Скинути пароль',
},
Expand Down
3 changes: 1 addition & 2 deletions packages/localizations/src/utils/enUS_v4.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,7 @@ export const enUS_v4: any = {
title: 'Reset Password',
formButtonPrimary: 'Reset Password',
successMessage: 'Your password was successfully changed. Signing you in, please wait a moment.',
requiredMessage:
'An account already exists with an unverified email address. Please reset your password for security.',
requiredMessage: 'For security reasons, it is required to reset your password.',
},
resetPasswordMfa: {
detailsLabel: 'We need to verify your identity before resetting your password.',
Expand Down
3 changes: 1 addition & 2 deletions packages/localizations/src/vi-VN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -371,8 +371,7 @@ export const viVN: LocalizationResource = {
},
resetPassword: {
formButtonPrimary: 'Đặt lại mật khẩu',
requiredMessage:
'An account already exists with an unverified email address. Please reset your password for security.',
requiredMessage: 'For security reasons, it is required to reset your password.',
successMessage: 'Mật khẩu của bạn đã được thay đổi thành công. Đang đăng nhập, vui lòng chờ một chút.',
title: 'Đặt lại mật khẩu',
},
Expand Down
3 changes: 1 addition & 2 deletions packages/localizations/src/zh-CN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -368,8 +368,7 @@ export const zhCN: LocalizationResource = {
},
resetPassword: {
formButtonPrimary: '重置密码',
requiredMessage:
'An account already exists with an unverified email address. Please reset your password for security.',
requiredMessage: 'For security reasons, it is required to reset your password.',
successMessage: '您的密码已成功更改。正在为您登录,请稍等。',
title: '重置密码',
},
Expand Down
3 changes: 1 addition & 2 deletions packages/localizations/src/zh-TW.ts
Original file line number Diff line number Diff line change
Expand Up @@ -368,8 +368,7 @@ export const zhTW: LocalizationResource = {
},
resetPassword: {
formButtonPrimary: '重設密碼',
requiredMessage:
'An account already exists with an unverified email address. Please reset your password for security.',
requiredMessage: 'For security reasons, it is required to reset your password.',
successMessage: '您的密碼已成功更改。正在為您登錄,請稍等。',
title: '重設密碼',
},
Expand Down
Loading