Update IFingerprintManager
Add FingerprintsHash to get registered fingerprints
This commit is contained in:
@@ -18,11 +18,13 @@ namespace Akari.Prototype.Server.Services
|
||||
{
|
||||
public const string FingerprintsPath = "fingerprints.json";
|
||||
|
||||
public IEnumerable<KeyValuePair<string, string>> FingerprintsHash => _fingerprintsHash;
|
||||
|
||||
private readonly ILogger<FingerprintManager> _logger;
|
||||
private readonly IAuthManager _authManager;
|
||||
private readonly AkariPath _akariPath;
|
||||
|
||||
private IDictionary<string, string> _tokensHash;
|
||||
private IDictionary<string, string> _fingerprintsHash;
|
||||
|
||||
public FingerprintManager(ILogger<FingerprintManager> logger, IAuthManager authManager, AkariPath akariPath)
|
||||
{
|
||||
@@ -40,14 +42,14 @@ namespace Akari.Prototype.Server.Services
|
||||
// Create new
|
||||
if (!File.Exists(path))
|
||||
{
|
||||
_tokensHash = new Dictionary<string, string>();
|
||||
_fingerprintsHash = new Dictionary<string, string>();
|
||||
|
||||
File.WriteAllText(path, JsonSerializer.Serialize(_tokensHash));
|
||||
File.WriteAllText(path, JsonSerializer.Serialize(_fingerprintsHash));
|
||||
}
|
||||
// Load
|
||||
else
|
||||
{
|
||||
_tokensHash = JsonSerializer.Deserialize<IDictionary<string, string>>(File.ReadAllText(path));
|
||||
_fingerprintsHash = JsonSerializer.Deserialize<IDictionary<string, string>>(File.ReadAllText(path));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,7 +59,7 @@ namespace Akari.Prototype.Server.Services
|
||||
|
||||
var handle = GCHandle.Alloc(token, GCHandleType.Pinned);
|
||||
|
||||
if (!_tokensHash.TryGetValue(name, out var hash))
|
||||
if (!_fingerprintsHash.TryGetValue(name, out var hash))
|
||||
{
|
||||
_logger.LogDebug($"No fingerprint exist with the name: {name}");
|
||||
|
||||
|
||||
@@ -8,6 +8,8 @@ namespace Akari.Prototype.Server.Services
|
||||
{
|
||||
public interface IFingerprintManager
|
||||
{
|
||||
IEnumerable<KeyValuePair<string, string>> FingerprintsHash { get; }
|
||||
|
||||
void VerifyFingerprint(string name, string token);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user