diff --git a/src/user/edit-user.js b/src/user/edit-user.js index e5cc143..26a9fcb 100644 --- a/src/user/edit-user.js +++ b/src/user/edit-user.js @@ -19,6 +19,8 @@ import React from 'react'; import { Form, Col } from 'react-bootstrap'; import Dialog from '../common/dialogs/dialog'; +import NotificationsDataManager from "../common/data-managers/notifications-data-manager"; +import NotificationsFactory from "../common/data-managers/notifications-factory"; class EditUserDialog extends React.Component { constructor(props) { @@ -41,10 +43,6 @@ class EditUserDialog extends React.Component { let user = {} user.id = this.props.user.id; - user.password = this.state.password; - user.confirmPassword = this.state.confirmPassword - user.oldpassword = this.state.oldPassword - if (this.state.username != null && this.state.username !== this.props.user.username){ user.username = this.state.username } @@ -61,6 +59,13 @@ class EditUserDialog extends React.Component { user.active = this.state.active } + if (this.state.password !== '' && this.state.oldPassword !== '' && this.state.password === this.state.confirmPassword) { + user.password = this.state.password; + user.oldpassword = this.state.oldPassword + } else if (this.state.password !== '' && this.state.password !== this.state.confirmPassword){ + NotificationsDataManager.addNotification(NotificationsFactory.UPDATE_ERROR("New password not correctly confirmed")) + } + this.props.onClose(user); } else { diff --git a/src/user/users.js b/src/user/users.js index d814ef5..a935e44 100644 --- a/src/user/users.js +++ b/src/user/users.js @@ -107,16 +107,12 @@ class Users extends Component { this.setState({ editModal: false }); if (data) { - if (data.password === data.confirmPassword) { - AppDispatcher.dispatch({ - type: 'users/start-edit', - data: data, - token: this.state.token, - currentUser: this.state.currentUser, - }); - } else { - NotificationsDataManager.addNotification(NotificationsFactory.UPDATE_ERROR("New password not correctly confirmed")) - } + AppDispatcher.dispatch({ + type: 'users/start-edit', + data: data, + token: this.state.token, + currentUser: this.state.currentUser, + }); } }