1
0
mirror of https://github.com/bitwarden/server.git synced 2025-02-16 01:51:21 +01:00

Change setup validation to use a dto (#1852)

This commit is contained in:
Oscar Hinton 2022-02-09 17:13:21 +01:00 committed by GitHub
parent 1b0d18a7c5
commit 6f2f475aa3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,7 +3,7 @@ using System.Collections.Generic;
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
@ -272,10 +272,8 @@ namespace Bit.Setup
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;
@ -326,5 +324,10 @@ namespace Bit.Setup
_context.Parameters.Add(_context.Args[i].Substring(1), _context.Args[i + 1]);
}
}
class InstallationValidationResponseModel
{
public bool Enabled { get; init; }
}
}
}