{{tokenRecord.accessor}}
{{tokenRecord.secret}}
diff --git a/ui/app/controllers/settings/tokens.js b/ui/app/controllers/settings/tokens.js index 4173de7f8..7de2da4b8 100644 --- a/ui/app/controllers/settings/tokens.js +++ b/ui/app/controllers/settings/tokens.js @@ -1,20 +1,53 @@ import Ember from 'ember'; -const { Controller, inject } = Ember; +const { Controller, inject, computed } = Ember; export default Controller.extend({ token: inject.service(), - actions: { - setTokenProperty(property, event) { - this.get('token').set(property, event.currentTarget.value); - }, + tokenRecord: null, + secret: computed.reads('token.secret'), + accessor: computed.reads('token.accessor'), + tokenIsValid: false, + tokenIsInvalid: false, + + actions: { clearTokenProperties() { this.get('token').setProperties({ secret: undefined, accessor: undefined, }); + this.setProperties({ + tokenIsValid: false, + tokenIsInvalid: false, + }); + }, + + verifyToken() { + const { secret, accessor } = this.getProperties('secret', 'accessor'); + + this.set('token.secret', secret); + this.get('store') + .findRecord('token', accessor) + .then( + token => { + this.set('token.accessor', accessor); + this.setProperties({ + tokenIsValid: true, + tokenIsInvalid: false, + tokenRecord: token, + }); + }, + () => { + this.set('token.secret', null); + this.setProperties({ + tokenIsInvalid: true, + tokenIsValid: false, + tokenRecord: null, + }); + } + ); }, }, }); diff --git a/ui/app/templates/settings/tokens.hbs b/ui/app/templates/settings/tokens.hbs index f6a41ef76..0208d9aee 100644 --- a/ui/app/templates/settings/tokens.hbs +++ b/ui/app/templates/settings/tokens.hbs @@ -16,21 +16,80 @@ -
Sent with every request to determine authorization
Sent with every request to determine authorization
-Used to look up authorized policies
Used to look up authorized policies
-Your token is valid and authorized for the following policies.
+The token secret and accessor you have provided do not match.
+{{tokenRecord.accessor}}
{{tokenRecord.secret}}
+ {{#if policy.description}} + {{policy.description}} + {{else}} + No description + {{/if}} +
+{{policy.rules}}
+