dropdown time unit chooser added for token expiration.

pull/477/head
William Kim 2013-08-14 15:13:12 -04:00
parent 7ab53795b1
commit 6f8143937e
2 changed files with 37 additions and 18 deletions

View File

@ -299,7 +299,7 @@ var ClientFormView = Backbone.View.extend({
},
toggleRefreshTokenTimeout:function () {
$("#refreshTokenValiditySeconds", this.$el).toggle();
$("#refreshTokenValidityTime", this.$el).toggle();
},
previewLogo:function(event) {
@ -366,10 +366,15 @@ var ClientFormView = Backbone.View.extend({
}
},
getFormTokenNumberValue:function(value) {
// rounds down to the nearest integer value in seconds.
getFormTokenNumberValue:function(value, timeUnit) {
if (value == "") {
return null;
} else {
} else if (timeUnit == 'hours') {
return parseInt(parseFloat(value) * 3600);
} else if (timeUnit == 'minutes') {
return parseInt(parseFloat(value) * 60);
} else { // seconds
return parseInt(value);
}
},
@ -429,12 +434,12 @@ var ClientFormView = Backbone.View.extend({
var accessTokenValiditySeconds = null;
if (!$('disableAccessTokenTimeout').is(':checked')) {
accessTokenValiditySeconds = this.getFormTokenNumberValue($('#accessTokenValiditySeconds input[type=text]').val());
accessTokenValiditySeconds = this.getFormTokenNumberValue($('#accessTokenValidityTime input[type=text]').val(), $('#accessTokenValidityTime select').val());
}
var idTokenValiditySeconds = null;
if (!$('disableIDTokenTimeout').is(':checked')) {
idTokenValiditySeconds = this.getFormTokenNumberValue($('#idTokenValiditySeconds input[type=text]').val());
idTokenValiditySeconds = this.getFormTokenNumberValue($('#idTokenValidityTime input[type=text]').val(), $('#idTokenValidityTime select').val());
}
var refreshTokenValiditySeconds = null;
@ -449,7 +454,7 @@ var ClientFormView = Backbone.View.extend({
}
if (!$('disableRefreshTokenTimeout').is(':checked')) {
refreshTokenValiditySeconds = this.getFormTokenNumberValue($('#refreshTokenValiditySeconds input[type=text]').val());
refreshTokenValiditySeconds = this.getFormTokenNumberValue($('#refreshTokenValidityTime input[type=text]').val(), $('#refreshTokenValidityTime select').val());
}
}
@ -607,7 +612,7 @@ var ClientFormView = Backbone.View.extend({
// set up token fields
if (!this.model.get("allowRefresh")) {
$("#refreshTokenValiditySeconds", this.$el).hide();
$("#refreshTokenValidityTime", this.$el).hide();
}
if (this.model.get("accessTokenValiditySeconds") == null) {

View File

@ -352,7 +352,7 @@
</div>
<div class="tab-pane" id="client-token-tab">
<div class="control-group" id="accessTokenValiditySeconds">
<div class="control-group" id="accessTokenValidityTime">
<label class="control-label">Access Token Timeout</label>
<div class="controls">
<div>
@ -361,14 +361,19 @@
</label>
</div>
<div class="input-append">
<input type="text" class="" value="<%=(accessTokenValiditySeconds == null ? '' : accessTokenValiditySeconds)%>" id="access-token-timeout-seconds" size="16"><span class="add-on">seconds</span>
<input type="text" class="" value="<%=(accessTokenValiditySeconds == null ? '' : accessTokenValiditySeconds)%>" id="access-token-timeout-seconds" size="16">
<select>
<option>seconds</option>
<option>minutes</option>
<option>hours</option>
</select>
</div>
<p class="help-block">Enter this time in seconds.</p>
<p class="help-block">Enter this time in seconds, minutes, or hours.</p>
</div>
</div>
<div class="control-group" id="idTokenValiditySeconds">
<div class="control-group" id="idTokenValidityTime">
<label class="control-label">ID Token Timeout</label>
<div class="controls">
<div>
@ -377,10 +382,14 @@
</label>
</div>
<div class="input-append">
<input type="text" class="" value="<%=(idTokenValiditySeconds == null ? '' : idTokenValiditySeconds)%>" id="id-token-timeout-seconds" size="16"><span
class="add-on">seconds</span>
<input type="text" class="" value="<%=(idTokenValiditySeconds == null ? '' : idTokenValiditySeconds)%>" id="id-token-timeout-seconds" size="16">
<select>
<option>seconds</option>
<option>minutes</option>
<option>hours</option>
</select>
</div>
<p class="help-block">Enter this time in seconds.</p>
<p class="help-block">Enter this time in seconds, minutes, or hours.</p>
</div>
</div>
@ -393,7 +402,7 @@
</div>
</div>
<div class="control-group" id="refreshTokenValiditySeconds">
<div class="control-group" id="refreshTokenValidityTime">
<div class="controls">
<div>
<label class="checkbox">
@ -406,9 +415,14 @@
</label>
</div>
<div class="input-append">
<input type="text" class="" value="<%=(refreshTokenValiditySeconds == null ? '' : refreshTokenValiditySeconds)%>" id="refresh-token-timeout-seconds" size="16"><span class="add-on">seconds</span>
</div>
<p class="help-block">Enter this time in seconds.</p>
<input type="text" class="" value="<%=(refreshTokenValiditySeconds == null ? '' : refreshTokenValiditySeconds)%>" id="refresh-token-timeout-seconds" size="16">
<select>
<option>seconds</option>
<option>minutes</option>
<option>hours</option>
</select>
</div>
<p class="help-block">Enter this time in seconds, minutes, or hours.</p>
</div>
</div>
</div>