Skip to content

USR-193 fix(clerk-js): Introduce ability to read multiple errors#1505

Merged
raptisj merged 4 commits intomainfrom
password_errors_refactor
Jul 26, 2023
Merged

USR-193 fix(clerk-js): Introduce ability to read multiple errors#1505
raptisj merged 4 commits intomainfrom
password_errors_refactor

Conversation

@raptisj
Copy link
Copy Markdown
Contributor

@raptisj raptisj commented Jul 21, 2023

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

Packages affected

  • @clerk/clerk-js
  • @clerk/clerk-react
  • @clerk/nextjs
  • @clerk/remix
  • @clerk/types
  • @clerk/themes
  • @clerk/localizations
  • @clerk/clerk-expo
  • @clerk/backend
  • @clerk/clerk-sdk-node
  • @clerk/shared
  • @clerk/fastify
  • @clerk/chrome-extension
  • gatsby-plugin-clerk
  • build/tooling/chore

Description

  • npm test runs as expected.
  • npm run build runs as expected.

Currently, client-side password validation constructs dynamically all error messages based on the password complexity settings. In this PR we want to support reading multiple errors in order to construct a password error with information
that comes from FAPI. This way we can achieve parity between password client-side validations and errors
returned from FAPI, resulting in the same exact message.

Currently, we support handling only one error object that comes from FAPI so if we have many errors regarding passwords(e.g. too short password, uppercase required, lowercase required) it will only show the first. We want the error handler to read all incoming errors(only password relating errors will be multiple) so a more concise password can be shown.

Before

Screen.Recording.2023-07-21.at.10.32.05.AM.mov

After

Screen.Recording.2023-07-20.at.7.05.52.PM.mov

@raptisj raptisj requested review from a team, desiprisg, dimkl, nikosdouvlis and panteliselef July 21, 2023 07:26
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Jul 21, 2023

🦋 Changeset detected

Latest commit: 3457bce

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@clerk/clerk-js Patch
@clerk/chrome-extension Patch
@clerk/clerk-expo Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Copy Markdown

@jit-ci jit-ci Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Great news! Jit hasn't found any security issues in your PR. Good Job! 🏆

Copy link
Copy Markdown
Contributor

@panteliselef panteliselef left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The UX feels like what we want to accomplish, let's focus on getting the code in the right state

Comment thread packages/clerk-js/src/ui/utils/errorHandler.ts Outdated
Comment thread packages/clerk-js/src/ui/utils/errorHandler.ts Outdated
Comment thread packages/clerk-js/src/ui/utils/passwordUtils.ts Outdated
Comment thread packages/clerk-js/src/ui/utils/passwordUtils.ts
@raptisj raptisj force-pushed the password_errors_refactor branch from 114d382 to 3c1d958 Compare July 21, 2023 15:41
Comment thread packages/clerk-js/src/ui/utils/formatStrings.ts Outdated
Comment thread packages/clerk-js/src/ui/utils/errorHandler.ts Outdated
@raptisj raptisj force-pushed the password_errors_refactor branch from 3c1d958 to e00ab20 Compare July 24, 2023 13:44
Comment thread packages/clerk-js/src/ui/utils/errorHandler.ts Outdated
Comment thread packages/clerk-js/src/ui/utils/errorHandler.ts Outdated
Comment thread packages/clerk-js/src/ui/utils/errorHandler.ts Outdated
@raptisj raptisj force-pushed the password_errors_refactor branch from fe2066d to faf6f13 Compare July 25, 2023 12:05
@raptisj raptisj marked this pull request as ready for review July 25, 2023 12:05
@raptisj raptisj requested a review from SokratisVidros as a code owner July 25, 2023 12:05
Comment thread packages/clerk-js/src/ui/components/SignIn/ResetPassword.tsx Outdated
Comment thread packages/clerk-js/src/ui/utils/errorHandler.ts Outdated
Comment thread packages/clerk-js/src/ui/utils/errorHandler.ts Outdated
Comment thread packages/clerk-js/src/ui/utils/errorHandler.ts Outdated
@raptisj raptisj force-pushed the password_errors_refactor branch from faf6f13 to 01a3661 Compare July 25, 2023 12:32
@SokratisVidros
Copy link
Copy Markdown
Contributor

!snapshot

@clerk-cookie
Copy link
Copy Markdown
Collaborator

Hey @SokratisVidros - the snapshot version command generated the following package versions:

Package Version
@clerk/backend 0.26.0
@clerk/chrome-extension 0.3.26-snapshot.01a3661
@clerk/clerk-js 4.54.3-snapshot.01a3661
eslint-config-custom 0.3.0
@clerk/clerk-expo 0.18.17-snapshot.01a3661
@clerk/fastify 0.6.2
gatsby-plugin-clerk 4.4.3
@clerk/localizations 1.24.0
@clerk/nextjs 4.23.1
@clerk/clerk-react 4.23.1
@clerk/remix 2.9.0
@clerk/clerk-sdk-node 4.12.1
@clerk/shared 0.20.0
@clerk/themes 1.7.5
@clerk/types 3.48.1

Tip: use the snippet copy button below to quickly install the required packages.

# @clerk/backend
npm i @clerk/backend@0.26.0
# @clerk/chrome-extension
npm i @clerk/chrome-extension@0.3.26-snapshot.01a3661
# @clerk/clerk-js
npm i @clerk/clerk-js@4.54.3-snapshot.01a3661
# eslint-config-custom
npm i eslint-config-custom@0.3.0
# @clerk/clerk-expo
npm i @clerk/clerk-expo@0.18.17-snapshot.01a3661
# @clerk/fastify
npm i @clerk/fastify@0.6.2
# gatsby-plugin-clerk
npm i gatsby-plugin-clerk@4.4.3
# @clerk/localizations
npm i @clerk/localizations@1.24.0
# @clerk/nextjs
npm i @clerk/nextjs@4.23.1
# @clerk/clerk-react
npm i @clerk/clerk-react@4.23.1
# @clerk/remix
npm i @clerk/remix@2.9.0
# @clerk/clerk-sdk-node
npm i @clerk/clerk-sdk-node@4.12.1
# @clerk/shared
npm i @clerk/shared@0.20.0
# @clerk/themes
npm i @clerk/themes@1.7.5
# @clerk/types
npm i @clerk/types@3.48.1

raptisj added 3 commits July 26, 2023 13:26
fix(clerk-js): Introduce ability to read multiple errors

fix(clerk-js): Introduce ability to read multiple errors
fix(clerk-js): Refactor addFullStop util

fix(clerk-js): Make handling of multiple errors more generic
@raptisj raptisj force-pushed the password_errors_refactor branch from 01a3661 to 54e0397 Compare July 26, 2023 10:26
Copy link
Copy Markdown
Contributor

@panteliselef panteliselef left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nicely done 🎉

Comment thread packages/clerk-js/src/ui/hooks/usePassword.ts Outdated
Comment thread packages/clerk-js/src/ui/utils/errorHandler.ts Outdated
Comment thread packages/clerk-js/src/ui/utils/passwordUtils.ts
| {
type: Extract<HTMLInputTypeAttribute, 'password'>;
validatePassword: boolean;
buildErrorMessage?: (err: ClerkAPIError[]) => ClerkAPIError | string | undefined;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️ Loving this, as it depends on the type of the input and not the name

Comment thread packages/clerk-js/src/ui/utils/errorHandler.ts Outdated
Comment thread packages/clerk-js/src/ui/utils/errorHandler.ts Outdated
Copy link
Copy Markdown
Member

@anagstef anagstef left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

@raptisj raptisj force-pushed the password_errors_refactor branch from 54e0397 to 3457bce Compare July 26, 2023 11:50
@raptisj raptisj changed the title fix(clerk-js): Introduce ability to read multiple errors USR-193 fix(clerk-js): Introduce ability to read multiple errors Jul 26, 2023
@raptisj raptisj merged commit 1d04d2c into main Jul 26, 2023
@raptisj raptisj deleted the password_errors_refactor branch July 26, 2023 12:04
@clerk-cookie clerk-cookie mentioned this pull request Jul 26, 2023
@clerk-cookie
Copy link
Copy Markdown
Collaborator

This PR has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@clerk clerk locked as resolved and limited conversation to collaborators Jul 26, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants