Update IMasterKeyService

Use an explicit property instead of a method for CheckConfig
This commit is contained in:
2021-06-07 15:39:59 +02:00
parent 76c9bd06af
commit ee9bc9ad33
2 changed files with 4 additions and 6 deletions

View File

@@ -9,8 +9,7 @@ namespace Akari.Prototype.Server.Services
public interface IMasterKeyService
{
public bool IsLoggedIn { get; }
public bool CheckConfig();
public bool IsPasswordSet { get; }
public bool Login(string password);

View File

@@ -20,6 +20,7 @@ namespace Akari.Prototype.Server.Services
public const int MasterKeyLength = 256 / 8;
public bool IsLoggedIn => _key is not null;
public bool IsPasswordSet => File.Exists(_akariPath.GetPath(ConfigPath));
private readonly ILogger<MasterKeyService> _logger;
private readonly AkariPath _akariPath;
@@ -33,8 +34,6 @@ namespace Akari.Prototype.Server.Services
_akariPath = akariPath;
}
public bool CheckConfig() => File.Exists(_akariPath.GetPath(ConfigPath));
public bool Login(string password)
{
if (_key is not null)
@@ -81,7 +80,7 @@ namespace Akari.Prototype.Server.Services
public bool CreatePassword(string password)
{
if (CheckConfig())
if (IsPasswordSet)
{
_logger.LogDebug("Tried to create password but it's already set.");
@@ -103,7 +102,7 @@ namespace Akari.Prototype.Server.Services
private bool LoadConfig()
{
if (!CheckConfig())
if (!IsPasswordSet)
{
return false;
}