From 48181c666660439eb7fa27a545fe340a2901d6f0 Mon Sep 17 00:00:00 2001 From: Qstick Date: Sat, 8 Jul 2017 08:04:27 -0400 Subject: [PATCH] Fixed: Ensure an API Key is set when starting Lidarr (#22) Fixed: Ensure an API Key is set when starting Lidarr --- .../Configuration/ConfigFileProvider.cs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/NzbDrone.Core/Configuration/ConfigFileProvider.cs b/src/NzbDrone.Core/Configuration/ConfigFileProvider.cs index a4586c4ad..8c12a5334 100644 --- a/src/NzbDrone.Core/Configuration/ConfigFileProvider.cs +++ b/src/NzbDrone.Core/Configuration/ConfigFileProvider.cs @@ -142,7 +142,21 @@ namespace NzbDrone.Core.Configuration public bool LaunchBrowser => GetValueBoolean("LaunchBrowser", true); - public string ApiKey => GetValue("ApiKey", GenerateApiKey()); + public string ApiKey + { + get + { + var apiKey = GetValue("ApiKey", GenerateApiKey()); + + if (apiKey.IsNullOrWhiteSpace()) + { + apiKey = GenerateApiKey(); + SetValue("ApiKey", apiKey); + } + + return apiKey; + } + } public AuthenticationType AuthenticationMethod {