From 33559b1ed94933ef129e8246ef78a8edcb9691c4 Mon Sep 17 00:00:00 2001 From: William Kim Date: Wed, 14 Aug 2013 15:13:12 -0400 Subject: [PATCH] dropdown time unit chooser added for token expiration. --- .../src/main/webapp/resources/js/client.js | 19 ++++++---- .../webapp/resources/template/client.html | 36 +++++++++++++------ 2 files changed, 37 insertions(+), 18 deletions(-) diff --git a/openid-connect-server/src/main/webapp/resources/js/client.js b/openid-connect-server/src/main/webapp/resources/js/client.js index 0380c6c81..919519acd 100644 --- a/openid-connect-server/src/main/webapp/resources/js/client.js +++ b/openid-connect-server/src/main/webapp/resources/js/client.js @@ -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); } }, @@ -453,12 +458,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; @@ -473,7 +478,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()); } } @@ -631,7 +636,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) { diff --git a/openid-connect-server/src/main/webapp/resources/template/client.html b/openid-connect-server/src/main/webapp/resources/template/client.html index 05bfd1349..b5783940a 100644 --- a/openid-connect-server/src/main/webapp/resources/template/client.html +++ b/openid-connect-server/src/main/webapp/resources/template/client.html @@ -353,7 +353,7 @@
-
+
@@ -362,14 +362,19 @@
- seconds + +
-

Enter this time in seconds.

+

Enter this time in seconds, minutes, or hours.

-
+
@@ -378,10 +383,14 @@
- seconds + +
-

Enter this time in seconds.

+

Enter this time in seconds, minutes, or hours.

@@ -394,7 +403,7 @@
-
+
- seconds -
-

Enter this time in seconds.

+ + +
+

Enter this time in seconds, minutes, or hours.