Reverted a NPE check to better support reflection method

This commit is contained in:
Joseph Milazzo 2021-05-14 08:17:57 -05:00
parent 03b49a5268
commit d1a7a4fd63

View File

@ -13,11 +13,10 @@ namespace Kavita.Common
var json = File.ReadAllText(filePath); var json = File.ReadAllText(filePath);
var jsonObj = JsonSerializer.Deserialize<dynamic>(json); var jsonObj = JsonSerializer.Deserialize<dynamic>(json);
const string key = "TokenKey"; const string key = "TokenKey";
JsonElement? tokenElement = null; if (jsonObj.TryGetProperty(key, out JsonElement tokenElement))
if (jsonObj?.TryGetProperty(key, out tokenElement))
{ {
return tokenElement?.GetString() != "super secret unguessable key"; return tokenElement.GetString() != "super secret unguessable key";
} }
return false; return false;