fix: Show error messages on invalid password edit
This commit is contained in:
@@ -14,6 +14,7 @@ import { Input, Popup } from '../../../lib/custom-ui';
|
||||
|
||||
import selectors from '../../../selectors';
|
||||
import entryActions from '../../../entry-actions';
|
||||
import actions from '../../../actions';
|
||||
import { useForm, useNestedRef } from '../../../hooks';
|
||||
import { isPassword } from '../../../utils/validator';
|
||||
|
||||
@@ -30,6 +31,11 @@ const createMessage = (error) => {
|
||||
type: 'error',
|
||||
content: 'common.invalidCurrentPassword',
|
||||
};
|
||||
case 'Invalid password':
|
||||
return {
|
||||
type: 'error',
|
||||
content: 'common.invalidPassword',
|
||||
};
|
||||
default:
|
||||
return {
|
||||
type: 'warning',
|
||||
@@ -69,11 +75,13 @@ const EditUserPasswordStep = React.memo(({ id, onBack, onClose }) => {
|
||||
const handleSubmit = useCallback(() => {
|
||||
if (!data.password || !isPassword(data.password)) {
|
||||
passwordFieldRef.current.select();
|
||||
dispatch(actions.updateUserPassword.failure(id, new Error('Invalid password')));
|
||||
return;
|
||||
}
|
||||
|
||||
if (withPasswordConfirmation && !data.currentPassword) {
|
||||
currentPasswordFieldRef.current.focus();
|
||||
dispatch(actions.updateUserPassword.failure(id, new Error('Invalid current password')));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user