Skip to content

Commit

Permalink
Change setup validation to use a dto (#1852)
Browse files Browse the repository at this point in the history
(cherry picked from commit 6f2f475)
  • Loading branch information
Hinton committed Feb 9, 2022
1 parent f5484ec commit 083b01d
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions util/Setup/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System.Data.SqlClient;
using System.Globalization;
using System.Net.Http;
using System.Text.Json;
using System.Net.Http.Json;
using Bit.Migrator;

namespace Bit.Setup
Expand Down Expand Up @@ -272,10 +272,8 @@ private static bool ValidateInstallation()
return false;
}

var resultString = response.Content.ReadAsStringAsync().GetAwaiter().GetResult();
using var jsonDocument = JsonSerializer.Deserialize<JsonDocument>(resultString);
var root = jsonDocument.RootElement;
if (!root.GetProperty("Enabled").GetBoolean())
var result = response.Content.ReadFromJsonAsync<InstallationValidationResponseModel>().GetAwaiter().GetResult();
if (!result.Enabled)
{
Console.WriteLine("Installation id has been disabled.");
return false;
Expand Down Expand Up @@ -326,5 +324,10 @@ private static void ParseParameters()
_context.Parameters.Add(_context.Args[i].Substring(1), _context.Args[i + 1]);
}
}

class InstallationValidationResponseModel
{
public bool Enabled { get; init; }
}
}
}

0 comments on commit 083b01d

Please sign in to comment.