Skip to content

Commit 1b51682

Browse files
committed
refactor(clerk-js): Simplify TaskResetPassword component by removing current password requirement and related fields
1 parent b8bab93 commit 1b51682

File tree

3 files changed

+15
-22
lines changed

3 files changed

+15
-22
lines changed

packages/clerk-js/src/ui/components/SessionTasks/tasks/TaskResetPassword/index.tsx

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ const TaskResetPasswordInternal = () => {
2121
const card = useCardState();
2222
const {
2323
userSettings: { passwordSettings },
24-
authConfig: { reverification },
2524
} = useEnvironment();
2625

2726
const { t, locale } = useLocalizations();
@@ -31,8 +30,6 @@ const TaskResetPasswordInternal = () => {
3130
(user: UserResource, opts: Parameters<UserResource['updatePassword']>) => user.updatePassword(...opts),
3231
);
3332

34-
const currentPasswordRequired = user && user.passwordEnabled && !reverification;
35-
3633
const handleSignOut = () => {
3734
if (otherSessions.length === 0) {
3835
return signOut(navigateAfterSignOut);
@@ -41,13 +38,6 @@ const TaskResetPasswordInternal = () => {
4138
return signOut(navigateAfterMultiSessionSingleSignOutUrl, { sessionId: session?.id });
4239
};
4340

44-
// TODO: remove this field
45-
const currentPasswordField = useFormControl('currentPassword', '', {
46-
type: 'password',
47-
label: localizationKeys('formFieldLabel__currentPassword'),
48-
isRequired: true,
49-
});
50-
5141
const passwordField = useFormControl('newPassword', '', {
5242
type: 'password',
5343
label: localizationKeys('formFieldLabel__newPassword'),
@@ -90,13 +80,12 @@ const TaskResetPasswordInternal = () => {
9080
try {
9181
await updatePasswordWithReverification(user, [
9282
{
93-
currentPassword: currentPasswordRequired ? currentPasswordField.value : undefined,
9483
newPassword: passwordField.value,
9584
signOutOfOtherSessions: sessionsField.checked,
9685
},
9786
]);
9887
} catch (e) {
99-
return handleError(e, [currentPasswordField, passwordField, confirmField], card.setError);
88+
return handleError(e, [passwordField, confirmField], card.setError);
10089
}
10190
};
10291

@@ -132,16 +121,6 @@ const TaskResetPasswordInternal = () => {
132121
value={session?.publicUserData.identifier || ''}
133122
style={{ display: 'none' }}
134123
/>
135-
{currentPasswordRequired && (
136-
<Form.ControlRow elementId={currentPasswordField.id}>
137-
<Form.PasswordInput
138-
{...currentPasswordField.props}
139-
minLength={6}
140-
isRequired
141-
autoFocus
142-
/>
143-
</Form.ControlRow>
144-
)}
145124
<Form.ControlRow elementId={passwordField.id}>
146125
<Form.PasswordInput
147126
{...passwordField.props}

packages/localizations/src/en-US.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -863,6 +863,13 @@ export const enUS: LocalizationResource = {
863863
actionText: 'Signed in as {{identifier}}',
864864
},
865865
},
866+
taskResetPassword: {
867+
title: 'Reset password',
868+
signOut: {
869+
actionLink: 'Sign out',
870+
actionText: 'Signed in as {{identifier}}',
871+
},
872+
},
866873
unstable__errors: {
867874
already_a_member_in_organization: '{{email}} is already a member of the organization.',
868875
captcha_invalid: undefined,

packages/shared/src/types/localization.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1287,6 +1287,13 @@ export type __internal_LocalizationResource = {
12871287
action__invitationAccept: LocalizationValue;
12881288
};
12891289
};
1290+
taskResetPassword: {
1291+
title: LocalizationValue;
1292+
signOut: {
1293+
actionLink: LocalizationValue;
1294+
actionText: LocalizationValue<'identifier'>;
1295+
};
1296+
};
12901297
};
12911298

12921299
type WithParamName<T> = T &

0 commit comments

Comments
 (0)