Skip to content

Commit 343e95d

Browse files
committed
refresh token table displays count of currently active access tokens, closes mitreid-connect#554
1 parent 665df2b commit 343e95d

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

openid-connect-server-webapp/src/main/webapp/resources/js/token.js

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ var RefreshTokenView = Backbone.View.extend({
231231
expirationDate = moment(expirationDate).calendar();
232232
}
233233

234-
var json = {token: this.model.toJSON(), client: this.options.client.toJSON(), formattedExpiration: expirationDate};
234+
var json = {token: this.model.toJSON(), client: this.options.client.toJSON(), formattedExpiration: expirationDate, accessTokenCount: this.options.accessTokenCount};
235235

236236
this.$el.html(this.template(json));
237237

@@ -420,7 +420,7 @@ var TokenListView = Backbone.View.extend({
420420

421421
// append and render the table structure
422422
$(this.el).html($('#tmpl-token-table').html());
423-
423+
424424
var _self = this;
425425

426426
// set up pagination
@@ -435,6 +435,9 @@ var TokenListView = Backbone.View.extend({
435435
$('.paginator-access', this.el).hide();
436436
}
437437

438+
// count up refresh tokens
439+
var refreshCount = {};
440+
438441
_.each(this.model.access.models, function (token, index) {
439442
// look up client
440443
var client = _self.options.clientList.getByClientId(token.get('clientId'));
@@ -444,10 +447,23 @@ var TokenListView = Backbone.View.extend({
444447
$('#access-token-table', _self.el).append(element);
445448
if (Math.ceil((index + 1) / 10) != 1) {
446449
$(element).hide();
450+
}
451+
452+
console.log(token.get('refreshTokenId'));
453+
var refId = token.get('refreshTokenId');
454+
if (refId != null) {
455+
if (refreshCount[refId]) {
456+
refreshCount[refId] += 1;
457+
} else {
458+
refreshCount[refId] = 1;
459+
}
460+
447461
}
448462

449463
});
450-
464+
465+
console.log(refreshCount);
466+
451467
// set up pagination
452468
var numPagesRefresh = Math.ceil(this.model.refresh.length / 10);
453469
if (numPagesRefresh > 1) {
@@ -463,7 +479,7 @@ var TokenListView = Backbone.View.extend({
463479
_.each(this.model.refresh.models, function (token, index) {
464480
// look up client
465481
var client = _self.options.clientList.getByClientId(token.get('clientId'));
466-
var view = new RefreshTokenView({model: token, client: client, systemScopeList: _self.options.systemScopeList});
482+
var view = new RefreshTokenView({model: token, client: client, systemScopeList: _self.options.systemScopeList, accessTokenCount: refreshCount[token.get('id')]});
467483
view.parentView = _self;
468484
var element = view.render().el;
469485
$('#refresh-token-table', _self.el).append(element);

openid-connect-server-webapp/src/main/webapp/resources/template/token.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@
127127
<td>
128128
<span title="<%= client.clientId %>"><%= client.clientName != null ? client.clientName : ( client.clientId.substr(0,8) + '...' ) %></span>
129129
<div class="client-more-info-block"></div>
130+
<span class="label label-info" title="Number of associated access tokens"><%= accessTokenCount %></span>
130131
</td>
131132

132133
<td>

0 commit comments

Comments
 (0)