Skip to content

Commit

Permalink
Merge pull request #270 from IFRCGo/fix/password-recover
Browse files Browse the repository at this point in the history
fix: recover password
  • Loading branch information
frozenhelium authored Oct 31, 2023
2 parents 74188a9 + 6b7cc45 commit bb67917
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/views/RecoverAccountConfirm/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import i18n from './i18n.json';
import styles from './styles.module.css';

interface FormFields {
newPassword?: string;
new_password?: string;
confirmPassword?: string;
}

Expand All @@ -55,22 +55,22 @@ function getPasswordMatchCondition(referenceVal: string | undefined) {
const formSchema: FormSchema = {
fields: (value): FormSchemaFields => {
let baseSchema = {
newPassword: {
new_password: {
required: true,
requiredValidation: requiredStringCondition,
},
};
baseSchema = addCondition(
baseSchema,
value,
['newPassword'],
['new_password'],
['confirmPassword'],
(val) => ({
confirmPassword: {
required: true,
requiredValidation: requiredStringCondition,
forceValue: undefinedValue,
validations: [getPasswordMatchCondition(val?.newPassword)],
validations: [getPasswordMatchCondition(val?.new_password)],
},
}),
);
Expand Down Expand Up @@ -98,7 +98,7 @@ export function Component() {
pending,
} = useLazyRequest({
method: 'POST',
url: '/change_password',
url: '/change_recover_password',
body: (body: ChangePasswordRequestBody) => body,
onSuccess: () => {
navigate('login');
Expand Down Expand Up @@ -129,7 +129,7 @@ export function Component() {
const handleChangePassword = useCallback(
(formValues: FormFields) => {
requestPasswordRecovery({
new_password: formValues.newPassword,
new_password: formValues.new_password,
token,
username,
} as ChangePasswordRequestBody);
Expand Down Expand Up @@ -160,11 +160,11 @@ export function Component() {
withFallbackError
/>
<PasswordInput
name="newPassword"
name="new_password"
label={strings.newPassword}
value={formValue.newPassword}
value={formValue.new_password}
onChange={setFieldValue}
error={fieldError?.newPassword}
error={fieldError?.new_password}
disabled={pending}
withAsterisk
autoFocus
Expand Down

0 comments on commit bb67917

Please sign in to comment.