diff --git a/openid-connect-server/src/main/java/org/mitre/openid/connect/web/ApprovedSiteAPI.java b/openid-connect-server/src/main/java/org/mitre/openid/connect/web/ApprovedSiteAPI.java index a233ace1b..7e1802c8d 100644 --- a/openid-connect-server/src/main/java/org/mitre/openid/connect/web/ApprovedSiteAPI.java +++ b/openid-connect-server/src/main/java/org/mitre/openid/connect/web/ApprovedSiteAPI.java @@ -59,10 +59,14 @@ public class ApprovedSiteAPI { if (approvedSite == null) { logger.error("deleteApprovedSite failed; no approved site found for id: " + id); m.put("code", HttpStatus.NOT_FOUND); + m.put("entity", "An error occurred while processing your request - no approved site found for id: " + id); + return "jsonEntityView"; } else if (!approvedSite.getUserId().equals(p.getName())) { logger.error("deleteApprovedSite failed; principal " + p.getName() + " does not own approved site" + id); m.put("code", HttpStatus.FORBIDDEN); + m.put("entity", "An error occurred while processing your request - you do not have permission to delete this approved site"); + return "jsonEntityView"; } else { m.put("code", HttpStatus.OK); approvedSiteService.remove(approvedSite); diff --git a/openid-connect-server/src/main/webapp/resources/js/grant.js b/openid-connect-server/src/main/webapp/resources/js/grant.js index 483cf0a0e..f71d0adbd 100644 --- a/openid-connect-server/src/main/webapp/resources/js/grant.js +++ b/openid-connect-server/src/main/webapp/resources/js/grant.js @@ -129,7 +129,22 @@ var ApprovedSiteView = Backbone.View.extend({ app.approvedSiteListView.togglePlaceholder(); }); }); - } + }, + 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!" + 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 + }); + } + }); app.approvedSiteListView.delegateEvents();