changed to dict-based model for saving
parent
8f4ecac8d5
commit
3268726747
|
@ -18,7 +18,7 @@ var ClientModel = Backbone.Model.extend({
|
||||||
defaults:{
|
defaults:{
|
||||||
id:null,
|
id:null,
|
||||||
idTokenValiditySeconds: 600,
|
idTokenValiditySeconds: 600,
|
||||||
clientName:"",
|
clientName:null,
|
||||||
clientSecret:"",
|
clientSecret:"",
|
||||||
redirectUris:[],
|
redirectUris:[],
|
||||||
grantTypes:["authorization_code"],
|
grantTypes:["authorization_code"],
|
||||||
|
@ -345,15 +345,14 @@ var ClientFormView = Backbone.View.extend({
|
||||||
clientSecret = $('#clientSecret input').val();
|
clientSecret = $('#clientSecret input').val();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: validate these as integers
|
|
||||||
var accessTokenValiditySeconds = null;
|
var accessTokenValiditySeconds = null;
|
||||||
if (!$('disableAccessTokenTimeout').is(':checked')) {
|
if (!$('disableAccessTokenTimeout').is(':checked')) {
|
||||||
accessTokenValiditySeconds = this.getFormTokenValue($('#accessTokenValiditySeconds input[type=text]').val());
|
accessTokenValiditySeconds = parseInt(this.getFormTokenValue($('#accessTokenValiditySeconds input[type=text]').val()));
|
||||||
}
|
}
|
||||||
|
|
||||||
var idTokenValiditySeconds = null;
|
var idTokenValiditySeconds = null;
|
||||||
if (!$('disableIDTokenTimeout').is(':checked')) {
|
if (!$('disableIDTokenTimeout').is(':checked')) {
|
||||||
idTokenValiditySeconds = this.getFormTokenValue($('#idTokenValiditySeconds input[type=text]').val());
|
idTokenValiditySeconds = parseInt(this.getFormTokenValue($('#idTokenValiditySeconds input[type=text]').val()));
|
||||||
}
|
}
|
||||||
|
|
||||||
var refreshTokenValiditySeconds = null;
|
var refreshTokenValiditySeconds = null;
|
||||||
|
@ -368,11 +367,11 @@ var ClientFormView = Backbone.View.extend({
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$('disableRefreshTokenTimeout').is(':checked')) {
|
if (!$('disableRefreshTokenTimeout').is(':checked')) {
|
||||||
refreshTokenValiditySeconds = this.getFormTokenValue($('#refreshTokenValiditySeconds input[type=text]').val());
|
refreshTokenValiditySeconds = parseInt(this.getFormTokenValue($('#refreshTokenValiditySeconds input[type=text]').val()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var valid = this.model.set({
|
var attrs = {
|
||||||
clientName:$('#clientName input').val(),
|
clientName:$('#clientName input').val(),
|
||||||
clientId:$('#clientId input').val(),
|
clientId:$('#clientId input').val(),
|
||||||
clientSecret: clientSecret,
|
clientSecret: clientSecret,
|
||||||
|
@ -402,7 +401,7 @@ var ClientFormView = Backbone.View.extend({
|
||||||
postLogoutRedirectUri: $('#postLogoutRedirectUri input').val(),
|
postLogoutRedirectUri: $('#postLogoutRedirectUri input').val(),
|
||||||
reuseRefreshToken: $('#reuseRefreshToken').is(':checked'), // TODO: another funny checkbox
|
reuseRefreshToken: $('#reuseRefreshToken').is(':checked'), // TODO: another funny checkbox
|
||||||
requireAuthTime: $('#requireAuthTime input').is(':checked'),
|
requireAuthTime: $('#requireAuthTime input').is(':checked'),
|
||||||
defaultMaxAge: $('#defaultMaxAge input').val(), // TODO: validate integer
|
defaultMaxAge: parseInt($('#defaultMaxAge input').val()),
|
||||||
contacts: this.contactsCollection.pluck('item'),
|
contacts: this.contactsCollection.pluck('item'),
|
||||||
requestUris: this.requestUrisCollection.pluck('item'),
|
requestUris: this.requestUrisCollection.pluck('item'),
|
||||||
defaultAcrValues: this.defaultAcrValuesCollection.pluck('item'),
|
defaultAcrValues: this.defaultAcrValuesCollection.pluck('item'),
|
||||||
|
@ -413,30 +412,34 @@ var ClientFormView = Backbone.View.extend({
|
||||||
idTokenSignedResponseAlg: $('#idTokenSignedResponseAlg select').val(),
|
idTokenSignedResponseAlg: $('#idTokenSignedResponseAlg select').val(),
|
||||||
idTokenEncryptedResponseAlg: $('#idTokenEncryptedResponseAlg select').val(),
|
idTokenEncryptedResponseAlg: $('#idTokenEncryptedResponseAlg select').val(),
|
||||||
idTokenEncryptedResponseEnc: $('#idTokenEncryptedResponseEnc select').val()
|
idTokenEncryptedResponseEnc: $('#idTokenEncryptedResponseEnc select').val()
|
||||||
});
|
};
|
||||||
|
|
||||||
// post-validate
|
// post-validate
|
||||||
// TODO: move these into the validation function somehow?
|
if (attrs["allowRefresh"] == false) {
|
||||||
if (this.model.get("allowRefresh") == false) {
|
attrs["refreshTokenValiditySeconds"] = null;
|
||||||
this.model.set("refreshTokenValiditySeconds",null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($('#disableIDTokenTimeout').is(':checked')) {
|
if ($('#disableIDTokenTimeout').is(':checked')) {
|
||||||
this.model.set("idTokenValiditySeconds",null);
|
attrs["idTokenValiditySeconds"] = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($('#disableAccessTokenTimeout').is(':checked')) {
|
if ($('#disableAccessTokenTimeout').is(':checked')) {
|
||||||
this.model.set("accessTokenValiditySeconds",null);
|
attrs["accessTokenValiditySeconds"] = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($('#disableRefreshTokenTimeout').is(':checked')) {
|
if ($('#disableRefreshTokenTimeout').is(':checked')) {
|
||||||
this.model.set("refreshTokenValiditySeconds",null);
|
attrs["refreshTokenValiditySeconds"] = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (valid) {
|
// set all empty strings to nulls
|
||||||
|
for (var key in attrs) {
|
||||||
|
if (attrs[key] === "") {
|
||||||
|
attrs[key] = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var _self = this;
|
var _self = this;
|
||||||
this.model.save({}, {
|
this.model.save(attrs, {
|
||||||
success:function () {
|
success:function () {
|
||||||
app.clientList.add(_self.model);
|
app.clientList.add(_self.model);
|
||||||
app.navigate('admin/clients', {trigger:true});
|
app.navigate('admin/clients', {trigger:true});
|
||||||
|
@ -445,7 +448,6 @@ var ClientFormView = Backbone.View.extend({
|
||||||
console.error("Oops! The object didn't save correctly.",resp);
|
console.error("Oops! The object didn't save correctly.",resp);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue