Implement change password functionality in JavaScript, React and Vue - #96
Draft
janithjay wants to merge 1 commit into
Draft
Implement change password functionality in JavaScript, React and Vue#96janithjay wants to merge 1 commit into
janithjay wants to merge 1 commit into
Conversation
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: trueThanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Signed-off-by: janithjay <janithjayashan018@gmail.com>
janithjay
force-pushed
the
pwd-change
branch
from
September 7, 2026 05:16
ecb5b0b to
25f4319
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Purpose
There is no SDK component for letting a user change their own password, so every integrator builds the form themselves against
POST /users/me/update-credentialsand re-implements validation, error handling, theming and i18n.This adds a
ChangePasswordcomponent to the React and Vue SDKs, with the shared logic in@thunderid/javascript. It also matches the contract change in thunder-id/thunderid#5290, where the endpoint began requiring the current password.flowchart TD A[Profile page loads] --> B{Does the user type<br/>declare a password?} B -->|no| C[Form rendered inert<br/>behind an explanation<br/>nothing is sent] B -->|yes| D[Form renders and submits] D --> E{Does the account have<br/>a password stored?} E -->|no| F["204<br/>first-time set"] E -->|yes| G{Is the current<br/>password correct?} G -->|yes| H["204"] G -->|no| I["403 USR-1029<br/>shown on the field"] style C fill:#fbeeec,stroke:#a8453a,color:#a8453a style F fill:#e7f3ec,stroke:#2c6a4c,color:#2c6a4c style H fill:#e7f3ec,stroke:#2c6a4c,color:#2c6a4cApproach
Shared logic sits in
@thunderid/javascriptso React and Vue cannot drift apart on it, and is re-exported through@thunderid/browserso consumers change no imports.flowchart TD react["@thunderid/react<br/>ChangePassword"] -->|depends on| browser["@thunderid/browser"] vue["@thunderid/vue<br/>ChangePassword"] -->|depends on| browser browser -->|depends on| core["@thunderid/javascript<br/>policy · form rules · error mapping"] style core fill:#e7f3ec,stroke:#2c6a4c,color:#2c6a4cCore
packages/javascript/src/api/updateMeCredentials.ts- the write. SendscurrentPasswordonly when present, so a first-time set on an account with no password still works.packages/javascript/src/utils/supportsPasswordCredential.ts- reads the user type schema and reports whetherpasswordis declared. The server rejects the write otherwise, so this stops the form submitting into a guaranteed failure. An unresolved schema counts as available, so nothing is hidden on missing information.packages/javascript/src/utils/resolveChangePasswordPolicy.ts- takes the rules from thepasswordattribute'sregexin the schema. The organization's policy is the only source of truth, the SDK adds no length or character-class rules of its own, which could otherwise reject a password the organization accepts.packages/javascript/src/utils/evaluatePasswordPolicy.tsandevaluateChangePasswordForm.ts- the live requirement checklist and every predicate the form needs, so both components stay pure rendering.isValiddeliberately excludescurrentPassword, see the note below.packages/javascript/src/utils/mapCredentialUpdateError.ts- decides which field a failure belongs on.403is the current password,400is the new password failing a server-side rule, anything else is form level.packages/javascript/src/constants/CredentialConstants.ts- thepasswordcredential key, previously a string literal in each component.packages/javascript/src/models/config.tsandutils/resolveResourceEndpoint.ts- add ausersMeCredentialsendpoint override, following the existingusersMeandusersMeMetapattern.packages/javascript/src/i18n/- new keys inmodels/i18n.tsand all nine locale files.React and Vue
.../ChangePassword/BaseChangePassword.tsxand.../change-password/BaseChangePassword.ts- presentational only. No context, no network calls: render the fields, show the checklist, emit validated values..../ChangePassword/ChangePassword.tsxand.../change-password/ChangePassword.ts- the context-wired variants that read config from the provider and perform the write..../ChangePassword/BaseChangePassword.styles.tsand.../change-password/ChangePassword.css.ts- Emotion for React, a CSS string for Vue, matching how presentation components are already built in each package.packages/vue/src/styles/injectStyles.ts- registers the new stylesheet. Missing this leaves the component silently unstyled..../primitives/PasswordFieldin both packages - gains anautoCompleteprop defaulting tocurrent-password, so the new and confirm fields can setnew-passwordand password managers offer to generate and store a credential rather than filling the existing one.Two decisions that are not obvious
403lands on the field instead, using a translated string rather than the server's message, so the response never reveals whether the account has a password.Related Issues
Related PRs
Checklist
breaking changelabel added.Security checks