From c1607b53e42cf21a0f40ffa621237b11acab5c2b Mon Sep 17 00:00:00 2001 From: William Kim Date: Mon, 12 Aug 2013 15:52:30 -0400 Subject: [PATCH] null-checking in date display for approved sites. --- .../src/main/webapp/resources/js/grant.js | 35 +++++++++++++------ 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/openid-connect-server/src/main/webapp/resources/js/grant.js b/openid-connect-server/src/main/webapp/resources/js/grant.js index aa6cd1fc9..fe0bd5c7f 100644 --- a/openid-connect-server/src/main/webapp/resources/js/grant.js +++ b/openid-connect-server/src/main/webapp/resources/js/grant.js @@ -118,21 +118,36 @@ var ApprovedSiteView = Backbone.View.extend({ render: function() { - var creationDate = moment(this.model.get("creationDate")); - var accessDate = moment(this.model.get("accessDate")); + var creationDate = this.model.get("creationDate"); + var accessDate = this.model.get("accessDate"); + var timeoutDate = this.model.get("timeoutDate"); - var timeoutDate = moment(this.model.get("timeoutDate")).calendar(); - - if (moment().diff(creationDate, 'months') < 6) { - creationDate = creationDate.fromNow(); + if (creationDate == null) { + creationDate = "Unknown"; } else { - creationDate = creationDate.format("MMMM Do, YYYY"); + creationDate = moment(creationDate); + if (moment().diff(creationDate, 'months') < 6) { + creationDate = creationDate.fromNow(); + } else { + creationDate = creationDate.format("MMMM Do, YYYY"); + } } - if (moment().diff(accessDate, 'months') < 6) { - accessDate = accessDate.fromNow(); + if (accessDate == null) { + accessDate = "Unknown"; } else { - accessDate = accessDate.format("MMMM Do, YYYY"); + accessDate = moment(accessDate); + if (moment().diff(accessDate, 'months') < 6) { + accessDate = accessDate.fromNow(); + } else { + accessDate = accessDate.format("MMMM Do, YYYY"); + } + } + + if (timeoutDate == null) { + timeoutDate = "Never"; + } else { + timeoutDate = moment(timeoutDate).calendar(); } var formattedDate = {creationDate: creationDate, accessDate: accessDate, timeoutDate: timeoutDate};