feat: implement Turnstile verification for enhanced security during login and registration

refactor: remove unnecessary interfaces for services; change user key from UID to UUID
This commit is contained in:
2025-12-31 12:11:09 -05:00
parent 08c4be4f7e
commit 848b8598e5
27 changed files with 579 additions and 84 deletions
@@ -0,0 +1,31 @@
using SharpbinV3.Server.Services.Verification.Providers;
namespace SharpbinV3.Server.Services.Verification
{
public sealed class VerificationService(IEnumerable<IVerificationProvider> providers)
{
private readonly IReadOnlyList<IVerificationProvider> _providers = [.. providers];
private IVerificationProvider? GetActiveProvider()
{
return _providers
.Where(p => p.IsConfigured)
.OrderByDescending(p => p.Priority)
.FirstOrDefault();
}
public async Task<bool> VerifyAsync(string? token, string? ip)
{
var provider = GetActiveProvider();
if (provider is null)
return true;
if (string.IsNullOrWhiteSpace(token))
return false;
return await provider.VerifyAsync(token, ip);
}
}
}