using ErsatzTV.Core.Domain;
using ErsatzTV.Core.Interfaces.Repositories;

namespace ErsatzTV.Application.Auth;

public class IsLocalAdminConfiguredHandler(IConfigElementRepository configElementRepository)
    : IRequestHandler<IsLocalAdminConfigured, bool>
{
    public async Task<bool> Handle(IsLocalAdminConfigured request, CancellationToken cancellationToken)
    {
        Option<ConfigElement> hash =
            await configElementRepository.GetConfigElement(ConfigElementKey.AuthLocalAdminPasswordHash, cancellationToken);
        return hash.IsSome;
    }
}
