diff --git a/src/user/edit-own-user.js b/src/user/edit-own-user.js index 81c9d9c..3ec5d23 100644 --- a/src/user/edit-own-user.js +++ b/src/user/edit-own-user.js @@ -34,12 +34,13 @@ class EditOwnUserDialog extends React.Component { this.state = { username: '', - currentpassword: '', mail: '', role: '', id: '', password: '', - active: '' + oldPassword: '', + active: '', + confirmpassword: '' } } @@ -68,7 +69,8 @@ class EditOwnUserDialog extends React.Component { var mail = true; var pw = true; var active = true; - var currentpassword = true; + var oldPassword = true; + var confirmpassword = true; if (this.state.username === '') { username = false; @@ -87,8 +89,12 @@ class EditOwnUserDialog extends React.Component { active = false; } - if(this.state.currentpassword === ''){ - currentpassword = false; + if(this.state.oldPassword === ''){ + oldPassword = false; + } + + if(this.state.confirmpassword === ''){ + confirmpassword = false; } @@ -98,7 +104,7 @@ class EditOwnUserDialog extends React.Component { }); // form is valid if any of the fields contain somethig - this.valid = username || role || active || currentpassword || mail || pw; + this.valid = username || role || active || oldPassword || mail || pw || confirmpassword; } @@ -124,14 +130,19 @@ class EditOwnUserDialog extends React.Component { E-mail this.handleChange(e)} /> - + Old Password - this.handleChange(e)} /> + this.handleChange(e)} /> New Password - this.handleChange(e)} /> + this.handleChange(e)} /> + + + + Confirm New Password + this.handleChange(e)} /> diff --git a/src/user/edit-user.js b/src/user/edit-user.js index d8ef87c..a30019a 100644 --- a/src/user/edit-user.js +++ b/src/user/edit-user.js @@ -36,7 +36,8 @@ class EditUserDialog extends React.Component { role: '', id: '', password: '', - active: '' + active: '', + confirmpassword: '' } } @@ -59,6 +60,8 @@ class EditUserDialog extends React.Component { var mail = true; var pw = true; var active = true; + var confirmpassword = true; + if (this.state.username === '') { username = false; @@ -80,8 +83,13 @@ class EditUserDialog extends React.Component { active = false; } + if(this.state.confirmpassword === ''){ + confirmpassword = false; + } + + // form is valid if any of the fields contain somethig - this.valid = username || role || mail || pw || active; + this.valid = username || role || mail || pw || active || confirmpassword; } @@ -109,7 +117,11 @@ class EditUserDialog extends React.Component { Password - this.handleChange(e)} /> + this.handleChange(e)} /> + + + Confirm New Password + this.handleChange(e)} /> Role diff --git a/src/user/user.js b/src/user/user.js index 9817069..69e6b1e 100644 --- a/src/user/user.js +++ b/src/user/user.js @@ -74,7 +74,7 @@ class User extends Component { console.log(data); if (data) { - + if(data.password === data.confirmpassword){ AppDispatcher.dispatch({ type: 'users/start-own-edit', @@ -82,6 +82,11 @@ class User extends Component { token: this.state.token }); } + + else{ + console.log("error: not the same password"); + } + } } @@ -115,7 +120,7 @@ class User extends Component { Role: {this.state.user.role} - + this.closeEditModal(data)} user={this.state.modalData} /> diff --git a/src/user/users.js b/src/user/users.js index 4cec1ef..c22e81f 100644 --- a/src/user/users.js +++ b/src/user/users.js @@ -93,12 +93,19 @@ 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 }); } + + else{ + console.log("error: not the same password"); + } + } } getHumanRoleName(role_key) {