-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Expand file tree
/
Copy pathtoken-expire-warning.js
More file actions
52 lines (45 loc) · 1.21 KB
/
token-expire-warning.js
File metadata and controls
52 lines (45 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: BUSL-1.1
*/
import Component from '@glimmer/component';
import { service } from '@ember/service';
import { tracked } from '@glimmer/tracking';
import { later } from '@ember/runloop';
import { task } from 'ember-concurrency';
export default class TokenExpireWarning extends Component {
@service auth;
@service router;
@tracked canDismiss = true;
handleRenew() {
return new Promise((resolve) => {
later(() => {
this.auth
.renew()
.then(() => {
// This renewal was triggered by an explicit user action,
// so this will reset the time inactive calculation
this.auth.setLastFetch(Date.now());
})
.finally(() => {
resolve();
});
}, 200);
});
}
@task
*renewToken() {
yield this.handleRenew();
}
get queryParams() {
// Bring user back to current page after login
return { redirect_to: this.router.currentURL };
}
get showWarning() {
const currentRoute = this.router.currentRouteName;
if ('vault.cluster.oidc-provider' === currentRoute) {
return false;
}
return !!this.args.expirationDate;
}
}