Fix Self-Service API key input prompt during install wizard, even if key is set

Fixes #52
This commit is contained in:
Christian Stein 2020-03-11 17:46:01 +01:00
parent 66eda2d71b
commit a040873e31

View file

@ -33,13 +33,16 @@ function Start-IcingaAgentDirectorWizard()
} }
if ($ForceTemplateKey -eq $FALSE) { if ($ForceTemplateKey -eq $FALSE) {
$SelfServiceAPIKey = $LocalAPIKey; if ([string]::IsNullOrEmpty($LocalAPIKey)) {
if ([string]::IsNullOrEmpty($SelfServiceAPIKey)) {
$LegacyTokenPath = Join-Path -Path Get-IcingaAgentConfigDirectory -ChildPath 'icingadirector.token'; $LegacyTokenPath = Join-Path -Path Get-IcingaAgentConfigDirectory -ChildPath 'icingadirector.token';
if (Test-Path $LegacyTokenPath) { if (Test-Path $LegacyTokenPath) {
$SelfServiceAPIKey = Get-Content -Path $LegacyTokenPath; $SelfServiceAPIKey = Get-Content -Path $LegacyTokenPath;
Set-IcingaPowerShellConfig -Path 'IcingaDirector.SelfService.ApiKey' -Value $SelfServiceAPIKey; Set-IcingaPowerShellConfig -Path 'IcingaDirector.SelfService.ApiKey' -Value $SelfServiceAPIKey;
} else {
$ForceTemplateKey = $TRUE;
} }
} else {
$SelfServiceAPIKey = $LocalAPIKey;
} }
} }