Skip to content

Commit

Permalink
#94 All orgadmin to update users and display error message in case of…
Browse files Browse the repository at this point in the history
… failure
  • Loading branch information
nadouani committed Apr 12, 2018
1 parent 0efa3d8 commit 3c1598d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,17 @@ export default class UserEditController {
return;
}

let postData = _.pick(this.formData, 'name', 'roles', 'organization');
let postData;
let promise;

if (
this.AuthService.currentUser.roles.indexOf(this.Roles.SUPERADMIN) !== -1
) {
postData = _.pick(this.formData, 'name', 'roles', 'organization');
} else {
postData = _.pick(this.formData, 'name', 'roles');
}

if (this.user.id) {
promise = this.UserService.update(this.user.id, postData);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,9 @@ export default class UsersListController {
`User ${mode === 'edit' ? 'updated' : 'created'} successfully`
);
})
.catch(rejection => {
if (rejection && rejection.type === 'ConflictError') {
// Handle user uniquness
.catch(err => {
if (!_.isString(err)) {
this.NotificationService.error('Unable to update the user.');
}
});
}
Expand Down

0 comments on commit 3c1598d

Please sign in to comment.