mirror of
https://github.com/hashicorp/vault.git
synced 2025-08-18 04:27:02 +02:00
47 lines
1.1 KiB
JavaScript
47 lines
1.1 KiB
JavaScript
/**
|
|
* Copyright (c) HashiCorp, Inc.
|
|
* SPDX-License-Identifier: BUSL-1.1
|
|
*/
|
|
|
|
import Component from '@glimmer/component';
|
|
import { inject as 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 showWarning() {
|
|
const currentRoute = this.router.currentRouteName;
|
|
if ('vault.cluster.oidc-provider' === currentRoute) {
|
|
return false;
|
|
}
|
|
return !!this.args.expirationDate;
|
|
}
|
|
}
|