mirror of
https://git.rwth-aachen.de/acs/public/villas/web/
synced 2025-03-09 00:00:01 +01:00
Move password confirmation check to edit user dialog
This commit is contained in:
parent
433c0918f2
commit
47ec6894f9
2 changed files with 15 additions and 14 deletions
|
@ -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 {
|
||||
|
|
|
@ -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,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue