diff --git a/client/css/user-view.styl b/client/css/user-view.styl index 9b10d260..3640cac9 100644 --- a/client/css/user-view.styl +++ b/client/css/user-view.styl @@ -1,6 +1,6 @@ #user width: 100% - max-width: 45em + max-width: 35em nav.text-nav margin-bottom: 1.5em @@ -51,22 +51,19 @@ flex-direction column; padding-bottom: 0.5em; - .floor - border-bottom: black solid 1px; - - .token-info - min-width: 75%; - - .token-actions - max-width: 25%; - justify-content: end; + .full-width + width: 100% .token-flex-row display: flex; flex-direction: row; justify-content: space-between; - padding-top: 0.25em; - padding-bottom: 0.25em; + padding: 0.2em; + + .token-input + min-height: 2em; + line-height: 2em; + text-align: center; form width: auto; @@ -75,6 +72,12 @@ display: flex; flex-direction: column; + .token-flex-labels + padding-right: 0.5em + + hr + border-top: 1px #aaa solid; + #user-delete form width: 100% diff --git a/client/html/user_tokens.tpl b/client/html/user_tokens.tpl index cd5901ce..84f3aa6e 100644 --- a/client/html/user_tokens.tpl +++ b/client/html/user_tokens.tpl @@ -3,63 +3,57 @@ <% if (ctx.tokens.length > 0) { %>
<% _.each(ctx.tokens, function(token, index) { %> -
-
-
-
Token:
-
<%= token.token %>
-
-
-
Note:
-
<%= token.note %>
-
-
-
Created:
-
<%= new Date(token.creationTime).toLocaleDateString() %>
-
+
+
+
Token:
+
Note:
+
Created:
+
Expires:
+
+
+
<%= token.token %>
+
<%= token.note %>
+
<%= ctx.makeRelativeTime(token.creationTime) %>
<% if (token.expirationTime) { %> -
-
Expires:
-
<%= new Date(token.expirationTime).toLocaleDateString() %>
-
+
<%= ctx.makeRelativeTime(token.expirationTime) %>
<% } else { %> -
-
Expires:
-
No Expiration
-
+
No expiration
<% } %>
-
-
+
+
+
+
- + <% if (token.isCurrentAuthToken) { %> + + <% } else { %> + + <% } %>
+
<% }); %>
<% } else { %>

No Registered Tokens

<% } %> -
-
-
-
-
Note:
-
-
-
-
Expiration:
-
-
-
-
- -
-
-
-
-
+
+
    +
  • + + +
  • +
  • + + +
  • +
+
+ +
+
diff --git a/client/js/api.js b/client/js/api.js index efb4c4b0..3d4787be 100644 --- a/client/js/api.js +++ b/client/js/api.js @@ -122,7 +122,7 @@ class Api extends events.EventTarget { createToken(userName, options) { let userTokenRequest = { enabled: true, - note: 'Client Login Token' + note: 'Web Login Token' }; if (typeof options.expires !== 'undefined') { userTokenRequest.expirationTime = new Date().addDays(options.expires).toISOString() @@ -212,6 +212,10 @@ class Api extends events.EventTarget { } } + isCurrentAuthToken(userToken) { + return userToken.token === this.token; + } + _getFullUrl(url) { const fullUrl = (config.apiUrl + '/' + url).replace(/([^:])\/+/g, '$1/'); diff --git a/client/js/controllers/user_controller.js b/client/js/controllers/user_controller.js index 786fb729..55987641 100644 --- a/client/js/controllers/user_controller.js +++ b/client/js/controllers/user_controller.js @@ -29,7 +29,10 @@ class UserController { if (section === 'list-tokens') { userTokenPromise = UserToken.get(userName) .then(userTokens => { - return userTokens; + return userTokens.map(token => { + token.isCurrentAuthToken = api.isCurrentAuthToken(token); + return token; + }); }, error => { return []; }); @@ -216,7 +219,7 @@ class UserController { _evtDeleteToken(e) { this._view.clearMessages(); this._view.disableForm(); - if (e.detail.userToken.token === api.token) { + if (api.isCurrentAuthToken(e.detail.userToken)) { router.show(uri.formatClientLink('logout')); } else { e.detail.userToken.delete(e.detail.user.name) diff --git a/client/js/views/user_tokens_view.js b/client/js/views/user_tokens_view.js index 7e19ca1e..bb81acc2 100644 --- a/client/js/views/user_tokens_view.js +++ b/client/js/views/user_tokens_view.js @@ -2,6 +2,7 @@ const events = require('../events.js'); const views = require('../util/views.js'); +const api = require('../api.js'); const template = views.getTemplate('user-tokens');