From e856a2c5c5026fff8deb3727645ce5f15268edc2 Mon Sep 17 00:00:00 2001 From: Michael Klein Date: Tue, 18 Oct 2022 16:16:42 +0200 Subject: [PATCH] Cleanup app boot by using hcp service --- .../consul-ui/app/routes/application.js | 28 ++----------------- 1 file changed, 2 insertions(+), 26 deletions(-) diff --git a/ui/packages/consul-ui/app/routes/application.js b/ui/packages/consul-ui/app/routes/application.js index 8f4838c95..e15642ef1 100644 --- a/ui/packages/consul-ui/app/routes/application.js +++ b/ui/packages/consul-ui/app/routes/application.js @@ -1,43 +1,19 @@ import Route from 'consul-ui/routing/route'; import { action } from '@ember/object'; import { inject as service } from '@ember/service'; -import { runInDebug } from '@ember/debug'; import WithBlockingActions from 'consul-ui/mixins/with-blocking-actions'; export default class ApplicationRoute extends Route.extend(WithBlockingActions) { @service('client/http') client; @service('env') env; - @service('repository/token') tokenRepo; - @service('settings') settings; + @service() hcp; data; async model() { if (this.env.var('CONSUL_ACLS_ENABLED')) { - const secret = this.env.var('CONSUL_HTTP_TOKEN'); - if (secret) { - const existing = await this.settings.findBySlug('token'); - - if (secret && secret !== existing.SecretID) { - try { - const token = await this.tokenRepo.self({ - secret: secret, - dc: this.env.var('CONSUL_DATACENTER_LOCAL'), - }); - await this.settings.persist({ - token: { - AccessorID: token.AccessorID, - SecretID: token.SecretID, - Namespace: token.Namespace, - Partition: token.Partition, - }, - }); - } catch (e) { - runInDebug((_) => console.error(e)); - } - } - } + await this.hcp.updateTokenIfNecessary(this.env.var('CONSUL_HTTP_TOKEN')); } return {}; }