diff --git a/openid-connect-server/src/main/java/org/mitre/oauth2/web/ScopeAPI.java b/openid-connect-server/src/main/java/org/mitre/oauth2/web/ScopeAPI.java index 4ac5dee3f..156e587e6 100644 --- a/openid-connect-server/src/main/java/org/mitre/oauth2/web/ScopeAPI.java +++ b/openid-connect-server/src/main/java/org/mitre/oauth2/web/ScopeAPI.java @@ -18,7 +18,6 @@ import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; import com.google.gson.Gson; @@ -123,7 +122,7 @@ public class ScopeAPI { } catch (RuntimeException e) { logger.error("There was an error attempting to save scope: " + scope + " : " + e.getStackTrace().toString()); m.put("code", HttpStatus.BAD_REQUEST); - m.put("entity", "An error occurred while processing your request"); + m.put("entity", "An error occurred while processing your request."); return "jsonEntityView"; } @@ -135,9 +134,10 @@ public class ScopeAPI { } else { logger.error("createScope failed; JSON was invalid: " + json); + m.put("entity", "An error occurred while processing your request - invalud JSON."); m.put("code", HttpStatus.BAD_REQUEST); - return "httpCodeView"; + return "jsonEntityView"; } } diff --git a/openid-connect-server/src/main/webapp/resources/js/scope.js b/openid-connect-server/src/main/webapp/resources/js/scope.js index 6d3743496..76f6cf176 100644 --- a/openid-connect-server/src/main/webapp/resources/js/scope.js +++ b/openid-connect-server/src/main/webapp/resources/js/scope.js @@ -84,10 +84,13 @@ var SystemScopeView = Backbone.View.extend({ }); }); }, - error:function () { + error:function (error, response) { + + //Pull out the response text. + var responseText = JSON.parse(response.responseText); //Display an alert with an error message - $('#modalAlert div.modal-body').html("
Warning! An error occurred when processing your request. Please refresh the page and try again.
"); + $('#modalAlert div.modal-body').html("
Warning!" + responseText + "
"); $("#modalAlert").modal({ // wire up the actual modal functionality and show the dialog "backdrop" : "static", @@ -236,10 +239,14 @@ var SystemScopeFormView = Backbone.View.extend({ app.navigate('admin/scope', {trigger: true}); }, error:function(error, response) { - if (response.status == 409) { + + //Pull out the response text. + var responseText = JSON.parse(response.responseText); + + if (response.status == 409) { //Conflict, scope already exists $('#value.control-group input').addClass('inputError'); - $('#value.control-group').before('
A scope with this value already exists, please choose a different value.
'); + $('#value.control-group').before('
' + responseText + '
'); $('#value.control-group').bind('click.error', function() { $('#value.control-group input').removeClass('inputError'); @@ -248,9 +255,14 @@ var SystemScopeFormView = Backbone.View.extend({ } else { - //TODO: if there are any other known error cases, catch those by response status and display - //appropriate messages. - $('#value.control-group').before('
A system error occurred when processing your request.
'); + //Display an alert with an error message + $('#modalAlert div.modal-body').html("
Warning!" + responseText + "
"); + + $("#modalAlert").modal({ // wire up the actual modal functionality and show the dialog + "backdrop" : "static", + "keyboard" : true, + "show" : true // ensure the modal is shown immediately + }); } } });