Skip to content

Commit

Permalink
show errors when editing users
Browse files Browse the repository at this point in the history
  • Loading branch information
dularion committed Feb 3, 2018
1 parent c3455e7 commit b7f022a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,15 @@ angular.module('streama').controller('modalUserCtrl', [
$uibModalInstance.close(data);
$scope.loading = false;
})
.error(function () {
.error(function (response) {
$scope.loading = false;
alertify.error('There was an error saving the user.');
if(_.get(response, 'errors')){
_.forEach(response.errors, function(error){
alertify.error('Error: ' + error.message);
});
}else{
alertify.error('There was an error saving the user.');
}
});
};

Expand Down
5 changes: 3 additions & 2 deletions grails-app/controllers/streama/UserController.groovy
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package streama

import grails.converters.JSON
import grails.transaction.Transactional

import static java.util.UUID.randomUUID
Expand Down Expand Up @@ -91,10 +92,10 @@ class UserController {
}

userInstance.properties = data

userInstance.validate()
if (userInstance.hasErrors()) {
render status: NOT_ACCEPTABLE
response.setStatus(NOT_ACCEPTABLE.value())
render (userInstance.errors as JSON)
return
}

Expand Down

0 comments on commit b7f022a

Please sign in to comment.