Fix `TokenSecretID`-handling
This commit is contained in:
parent
12a923c658
commit
955949998f
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue