diff --git a/openid-connect-server/src/main/webapp/resources/js/admin.js b/openid-connect-server/src/main/webapp/resources/js/admin.js index 4a2f1343b..2fef08a50 100644 --- a/openid-connect-server/src/main/webapp/resources/js/admin.js +++ b/openid-connect-server/src/main/webapp/resources/js/admin.js @@ -333,6 +333,7 @@ var AppRouter = Backbone.Router.extend({ "dev/dynreg":"dynReg", "dev/dynreg/new":"newDynReg", + "dev/dynreg/edit":"editDynReg", "": "root" @@ -664,6 +665,17 @@ var AppRouter = Backbone.Router.extend({ $('#content').html(this.dynRegEditView.render().el); setPageTitle("Register a New Client"); + }, + + editDynReg:function() { + this.breadCrumbView.collection.reset(); + this.breadCrumbView.collection.add([ + {text:"Home", href:""}, + {text:"Client Registration", href:"manage/#dev/dynreg"}, + {text:"New", href:"manage/#dev/dynreg/new"} + ]); + + setPageTitle("Edit a New Client"); } diff --git a/openid-connect-server/src/main/webapp/resources/js/dynreg.js b/openid-connect-server/src/main/webapp/resources/js/dynreg.js index 28deda8c4..91df34f4f 100644 --- a/openid-connect-server/src/main/webapp/resources/js/dynreg.js +++ b/openid-connect-server/src/main/webapp/resources/js/dynreg.js @@ -41,6 +41,24 @@ var DynRegClient = Backbone.Model.extend({ request_uris:[], client_description:null, + + registration_access_token:null, + registration_client_uri:null + }, + + sync: function(method, model, options){ + console.log('Sync! ' + method); + console.log(model); + console.log(options); + if (model.get('registration_access_token')) { + var headers = options.headers ? options.headers : {}; + headers['Authorization'] = 'Bearer ' + model.get('registration_access_token'); + options.headers = headers; + console.log('Added token to request'); + console.log(options); + } + + return this.constructor.__super__.sync(method, model, options); }, urlRoot:'register' @@ -71,7 +89,25 @@ var DynRegRootView = Backbone.View.extend({ }, editReg:function() { + var clientId = $('#clientId').val(); + var token = $('#regtoken').val(); + + var client = new DynRegClient(); + client.set({ + client_id: clientId, + registration_access_token: token + }, { silent: true }); + + console.log(client.get('registration_access_token')); + + client.fetch(); + console.log(client); + + var dynRegEditView = new DynRegEditView({model: client}); + this.remove(); + $('#content').html(dynRegEditView.render().el); + app.navigate('dev/dynreg/edit', {trigger: true}); } }); diff --git a/openid-connect-server/src/main/webapp/resources/template/dynreg.html b/openid-connect-server/src/main/webapp/resources/template/dynreg.html index 5f25d1f50..2677cd428 100644 --- a/openid-connect-server/src/main/webapp/resources/template/dynreg.html +++ b/openid-connect-server/src/main/webapp/resources/template/dynreg.html @@ -67,6 +67,21 @@ + +