-
Notifications
You must be signed in to change notification settings - Fork 409
feat(clerk-js): Untrusted password screen for sign-in #7331
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
Open
octoper
wants to merge
29
commits into
main
Choose a base branch
from
vaggelis/user-4007-dont-allow-untrusted-passwords-to-be-able-to-sign-in
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+355
−19
Open
Changes from 28 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
4fb338f
feat(clerk-js): Initial work for reset password task
octoper 04ec552
fix(clerk-js): Rename variable for clarity in SignInFactorOne component
octoper 15ec15e
revert(clerk-js): Remove the logic for sign-in error on untrusted pas…
octoper 9b999dd
refactor(clerk-js): Remove 'untrustedPasswordMethods' from FlowMetada…
octoper 38076d6
refactor(localization): Remove 'passwordUntrusted' key from en-US loc…
octoper 81efac2
fix(clerk-js): Update buildTasksUrl method to accept optional redirec…
octoper 6521a3f
fix(clerk-js): Update buildTasksUrl method to accept optional TasksRe…
octoper ef4cde6
feat(clerk-js,backend): Implement reset password session task and rel…
octoper 93183fe
fix(clerk-js): Revert navigation changes from TaskChooseOrganization
octoper 39b8541
feat(clerk-js): Introduce 'passwordUntrusted' flow
octoper 74400d5
feat(clerk-js): Initial work for reset password task
octoper c003f6d
revert(clerk-js): Remove the logic for sign-in error on untrusted pas…
octoper a639180
refactor(localization): Remove 'passwordUntrusted' key from en-US loc…
octoper b8c4e62
Fix navigation to n+1 task within modal
LauraBeatris 17e1629
fix(clerk-js): Update token handling in Session class to ensure corre…
octoper 326e221
fix(clerk-js): Enhance token resolve to ensure accurate token retriev…
octoper ecc3697
fix(clerk-js): Update token caching to use Promise.resolve for last a…
octoper d16cae5
revert changes
octoper cf616d1
chore: Remove stale changes
octoper 87f9c52
chore: Remove stale changes
octoper 638e43d
fix(localization,shared): Add localization types
octoper 548c7c3
fix(clerk-js,shared): Export and use isPasswordUntrustedError
octoper 53de236
fix(localization): Add en-US localization
octoper b5f7793
chore(repo): Add changeset
octoper 79a274a
tests(clerk-js): Add unit test for untrusted password screen
octoper c9ec623
chore: Remove console.log from tests
octoper c525144
feat(localizations): Generate all localizations
octoper e64e9cf
feat: Update password error handling and localization for untrusted p…
octoper a09bc8a
fix(clerk-js): Fix error message
octoper File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| '@clerk/localizations': minor | ||
| '@clerk/clerk-js': minor | ||
| '@clerk/shared': minor | ||
| --- | ||
|
|
||
| Introduce a new variant for the alternative methods screen to handle untrusted password error on sign-in |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -352,6 +352,84 @@ describe('SignInFactorOne', () => { | |
| ), | ||
| ).not.toBeInTheDocument(); | ||
| }); | ||
|
|
||
| it('using an untrusted password should show the untrusted password screen', async () => { | ||
| const { wrapper, fixtures } = await createFixtures(f => { | ||
| f.withEmailAddress(); | ||
| f.withPassword(); | ||
| f.withPreferredSignInStrategy({ strategy: 'password' }); | ||
| f.startSignInWithEmailAddress({ | ||
| supportEmailCode: true, | ||
| supportPassword: true, | ||
| supportResetPassword: true, | ||
| }); | ||
| }); | ||
| fixtures.signIn.prepareFirstFactor.mockReturnValueOnce(Promise.resolve({} as SignInResource)); | ||
|
|
||
| const errJSON = { | ||
| code: 'form_password_untrusted', | ||
| long_message: | ||
| "Your appears to have been compromised or it's no longer trusted and cannot be used. Please use another method to continue.", | ||
| message: | ||
| "Your appears to have been compromised or it's no longer trusted and cannot be used. Please use another method to continue.", | ||
| meta: { param_name: 'password' }, | ||
| }; | ||
octoper marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| fixtures.signIn.attemptFirstFactor.mockRejectedValueOnce( | ||
| new ClerkAPIResponseError('Error', { | ||
| data: [errJSON], | ||
| status: 422, | ||
| }), | ||
| ); | ||
| const { userEvent } = render(<SignInFactorOne />, { wrapper }); | ||
| await userEvent.type(screen.getByLabelText('Password'), '123456'); | ||
| await userEvent.click(screen.getByText('Continue')); | ||
|
|
||
| await screen.findByText('Password compromised'); | ||
| await screen.findByText( | ||
| "Your appears to have been compromised or it's no longer trusted and cannot be used. Please use another method to continue.", | ||
| ); | ||
|
|
||
| await screen.findByText('Email code to [email protected]'); | ||
| }); | ||
|
|
||
| it('Prompts the user to use a different method if the password is untrusted', async () => { | ||
| const { wrapper, fixtures } = await createFixtures(f => { | ||
| f.withEmailAddress(); | ||
| f.withPassword(); | ||
| f.withPreferredSignInStrategy({ strategy: 'password' }); | ||
| f.withSocialProvider({ provider: 'google', authenticatable: true }); | ||
| f.startSignInWithEmailAddress({ | ||
| supportEmailCode: true, | ||
| supportPassword: true, | ||
| supportResetPassword: true, | ||
| }); | ||
| }); | ||
| fixtures.signIn.prepareFirstFactor.mockReturnValueOnce(Promise.resolve({} as SignInResource)); | ||
|
|
||
| const errJSON = { | ||
| code: 'form_password_untrusted', | ||
| long_message: | ||
| "Your appears to have been compromised or it's no longer trusted and cannot be used. Please use another method to continue.", | ||
| message: | ||
| "Your appears to have been compromised or it's no longer trusted and cannot be used. Please use another method to continue.", | ||
| meta: { param_name: 'password' }, | ||
| }; | ||
octoper marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| fixtures.signIn.attemptFirstFactor.mockRejectedValueOnce( | ||
| new ClerkAPIResponseError('Error', { | ||
| data: [errJSON], | ||
| status: 422, | ||
| }), | ||
| ); | ||
| const { userEvent } = render(<SignInFactorOne />, { wrapper }); | ||
| await userEvent.type(screen.getByLabelText('Password'), '123456'); | ||
| await userEvent.click(screen.getByText('Continue')); | ||
|
|
||
| await screen.findByText('Password compromised'); | ||
| await userEvent.click(screen.getByText('Email code to [email protected]')); | ||
| await screen.findByText('Check your email'); | ||
| }); | ||
| }); | ||
|
|
||
| describe('Forgot Password', () => { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.