mirror of https://github.com/status-im/consul.git
Fix `TokenSecretID`-handling
This commit is contained in:
parent
cc25602df1
commit
dcdcdbc5ea
|
@ -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