From 92be78f509259c812438e608b7f171469d14ca65 Mon Sep 17 00:00:00 2001 From: Shekar Siri Date: Mon, 30 Jan 2023 14:10:55 +0100 Subject: [PATCH] fix(ui) - password reset error check --- .../Client/ProfileSettings/ChangePassword.js | 21 ++++++++++--------- frontend/app/duck/user.js | 2 +- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/frontend/app/components/Client/ProfileSettings/ChangePassword.js b/frontend/app/components/Client/ProfileSettings/ChangePassword.js index d0222abf0..2640ab612 100644 --- a/frontend/app/components/Client/ProfileSettings/ChangePassword.js +++ b/frontend/app/components/Client/ProfileSettings/ChangePassword.js @@ -3,6 +3,7 @@ import { connect } from 'react-redux'; import { Button, Message, Form, Input } from 'UI'; import styles from './profileSettings.module.css'; import { updatePassword } from 'Duck/user'; +import { toast } from 'react-toastify'; const ERROR_DOESNT_MATCH = "Passwords doesn't match"; const MIN_LENGTH = 8; @@ -48,12 +49,15 @@ export default class ChangePassword extends React.PureComponent { oldPassword, newPassword, }) - .then(() => { - if (this.props.passwordErrors.size === 0) { - this.setState({ - ...defaultState, - success: true, - }); + .then((e) => { + const success = !e || !e.errors || e.errors.length === 0; + this.setState({ + ...defaultState, + success: success, + show: !success + }); + if (success) { + toast.success(`Successfully changed password`); } }); }; @@ -98,7 +102,7 @@ export default class ChangePassword extends React.PureComponent { -
+
@@ -107,9 +111,6 @@ export default class ChangePassword extends React.PureComponent { Cancel
- ) : (
this.setState({ show: true })}> diff --git a/frontend/app/duck/user.js b/frontend/app/duck/user.js index ce0f66fec..d938c8c09 100644 --- a/frontend/app/duck/user.js +++ b/frontend/app/duck/user.js @@ -59,7 +59,7 @@ const reducer = (state = initialState, action = {}) => { case RESET_PASSWORD.SUCCESS: case UPDATE_PASSWORD.SUCCESS: case LOGIN.SUCCESS: - state.set('account', Account({...action.data.user })).set('loginRequest', { loading: false, errors: [] }) + state.set('account', Account({...action.data.user })).set('loginRequest', { loading: false, errors: [] }).set('passwordErrors', List()) case SIGNUP.SUCCESS: state.set('account', Account(action.data.user)).set('onboarding', true); case REQUEST_RESET_PASSWORD.SUCCESS: