From dcdcdbc5ea9d95e903fea6c487e15133c6660d87 Mon Sep 17 00:00:00 2001 From: Michael Klein Date: Tue, 18 Oct 2022 16:07:48 +0200 Subject: [PATCH] Fix `TokenSecretID`-handling --- .../consul-ui/app/routes/application.js | 37 ++++++++++--------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/ui/packages/consul-ui/app/routes/application.js b/ui/packages/consul-ui/app/routes/application.js index dd81c34984..8f4838c95a 100644 --- a/ui/packages/consul-ui/app/routes/application.js +++ b/ui/packages/consul-ui/app/routes/application.js @@ -16,23 +16,26 @@ export default class ApplicationRoute extends Route.extend(WithBlockingActions) async model() { if (this.env.var('CONSUL_ACLS_ENABLED')) { const secret = this.env.var('CONSUL_HTTP_TOKEN'); - const existing = await this.settings.findBySlug('token'); - if (!existing.AccessorID && secret) { - 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)); + 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)); + } } } }