added client read and oauth token support for CRUD abilities

pull/485/merge
Justin Richer 11 years ago
parent ead99474be
commit 36151975c1

@ -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");
}

@ -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});
}
});

@ -67,6 +67,21 @@
</div>
</div>
<div class="control-group" id="clientId">
<label class="control-label">Client Configuration URL</label>
<div class="controls">
<%=registration_client_uri ? registration_client_uri : 'Will be generated'%>
</div>
</div>
<div class="control-group" id="clientId">
<label class="control-label">Registration Access Token</label>
<div class="controls">
<%=registration_access_token ? registration_access_token : 'Will be generated'%>
</div>
</div>
<div class="control-group" id="clientName">
<label class="control-label">Client name</label>
<div class="controls">

Loading…
Cancel
Save