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:
parent
404ab74ce1
commit
8e5180188e
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user