refactor(ConsumerApiService): Schnittstelle zum Lesen von ConsumerApi und zum Überprüfen der Passwörter erstellt.

- Implementiert als ConsumerApiJsonBasedService, um Daten aus einer json-Datei zu lesen.
This commit is contained in:
Developer 02 2025-01-15 10:03:10 +01:00
parent 404ab74ce1
commit 8e5180188e
2 changed files with 30 additions and 0 deletions

View File

@ -0,0 +1,19 @@
using DigitalData.Auth.API.Dto;
using DigitalData.Auth.API.Services.Contracts;
using Microsoft.Extensions.Options;
namespace DigitalData.Auth.API.Services
{
public class ConsumerApiJsonBasedService : IConsumerApiService
{
private readonly IEnumerable<ConsumerApi> _consumerAPIs;
public ConsumerApiJsonBasedService(IOptions<IEnumerable<ConsumerApi>> options)
{
_consumerAPIs = options.Value;
}
public Task<ConsumerApi?> ReadByNameAsync(string name) => Task.Run(() => _consumerAPIs.FirstOrDefault(api => api.Name == name));
public async Task<bool> VerifyAsync(ConsumerApiLogin login, string password) => (await ReadByNameAsync(login.Name))?.Password == password;
}
}

View File

@ -0,0 +1,11 @@
using DigitalData.Auth.API.Dto;
namespace DigitalData.Auth.API.Services.Contracts
{
public interface IConsumerApiService
{
public Task<ConsumerApi?> ReadByNameAsync(string name);
public Task<bool> VerifyAsync(ConsumerApiLogin login, string password);
}
}