fix: Show error messages on invalid password edit

This commit is contained in:
Ayman
2026-07-10 20:38:08 +01:00
parent 180807a0ec
commit 9443b85517
@@ -14,6 +14,7 @@ import { Input, Popup } from '../../../lib/custom-ui';
import selectors from '../../../selectors'; import selectors from '../../../selectors';
import entryActions from '../../../entry-actions'; import entryActions from '../../../entry-actions';
import actions from '../../../actions';
import { useForm, useNestedRef } from '../../../hooks'; import { useForm, useNestedRef } from '../../../hooks';
import { isPassword } from '../../../utils/validator'; import { isPassword } from '../../../utils/validator';
@@ -30,6 +31,11 @@ const createMessage = (error) => {
type: 'error', type: 'error',
content: 'common.invalidCurrentPassword', content: 'common.invalidCurrentPassword',
}; };
case 'Invalid password':
return {
type: 'error',
content: 'common.invalidPassword',
};
default: default:
return { return {
type: 'warning', type: 'warning',
@@ -69,11 +75,13 @@ const EditUserPasswordStep = React.memo(({ id, onBack, onClose }) => {
const handleSubmit = useCallback(() => { const handleSubmit = useCallback(() => {
if (!data.password || !isPassword(data.password)) { if (!data.password || !isPassword(data.password)) {
passwordFieldRef.current.select(); passwordFieldRef.current.select();
dispatch(actions.updateUserPassword.failure(id, new Error('Invalid password')));
return; return;
} }
if (withPasswordConfirmation && !data.currentPassword) { if (withPasswordConfirmation && !data.currentPassword) {
currentPasswordFieldRef.current.focus(); currentPasswordFieldRef.current.focus();
dispatch(actions.updateUserPassword.failure(id, new Error('Invalid current password')));
return; return;
} }