File tree Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Expand file tree Collapse file tree 2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -11,4 +11,16 @@ export default class TokenSettingsRoute extends AuthenticatedRoute {
11
11
let apiTokens = await this . store . findAll ( 'api-token' ) ;
12
12
return TrackedArray . from ( apiTokens . slice ( ) ) ;
13
13
}
14
+
15
+ /**
16
+ * Ensure that all plaintext tokens are deleted from memory after leaving
17
+ * the API tokens settings page.
18
+ */
19
+ resetController ( controller ) {
20
+ for ( let token of controller . model ) {
21
+ if ( token . token ) {
22
+ token . token = undefined ;
23
+ }
24
+ }
25
+ }
14
26
}
Original file line number Diff line number Diff line change @@ -133,6 +133,25 @@ module('Acceptance | api-tokens', function (hooks) {
133
133
assert . dom ( '[data-test-token]' ) . hasText ( token . token ) ;
134
134
} ) ;
135
135
136
+ test ( 'API tokens are only visible in plaintext until the page is left' , async function ( assert ) {
137
+ prepare ( this ) ;
138
+
139
+ await visit ( '/settings/tokens' ) ;
140
+ await click ( '[data-test-new-token-button]' ) ;
141
+ await fillIn ( '[data-test-focused-input]' , 'the new token' ) ;
142
+ await click ( '[data-test-save-token-button]' ) ;
143
+
144
+ let token = this . server . schema . apiTokens . findBy ( { name : 'the new token' } ) ;
145
+ assert . dom ( '[data-test-token]' ) . hasText ( token . token ) ;
146
+
147
+ // leave the API tokens page
148
+ await visit ( '/settings' ) ;
149
+
150
+ // and visit it again
151
+ await visit ( '/settings/tokens' ) ;
152
+ assert . dom ( '[data-test-token]' ) . doesNotExist ( ) ;
153
+ } ) ;
154
+
136
155
test ( 'navigating away while creating a token does not keep it in the list' , async function ( assert ) {
137
156
prepare ( this ) ;
138
157
You can’t perform that action at this time.
0 commit comments