elsa-core/src/modules/Elsa.Identity/Services/DefaultUserCredentialsValidator.cs
Sipke Schoorstra 8fb797eaeb
Remove Elsa.Expressions.Dsl module and related DSL features
This commit completely removes the Elsa.Expressions.Dsl module, including all associated features, services, models, and dependencies. The DSL functionality, including its custom activities and integration options, has been fully eliminated from the project.
2025-06-02 21:52:10 +02:00

36 lines
1.1 KiB
C#

using Elsa.Extensions;
using Elsa.Identity.Contracts;
using Elsa.Identity.Entities;
namespace Elsa.Identity.Services;
/// <summary>
/// Validates user credentials
/// </summary>
public class DefaultUserCredentialsValidator : IUserCredentialsValidator
{
private readonly IUserProvider _userProvider;
private readonly ISecretHasher _secretHasher;
/// <summary>
/// Initializes a new instance of the <see cref="DefaultUserCredentialsValidator"/> class.
/// </summary>
public DefaultUserCredentialsValidator(IUserProvider userProvider, ISecretHasher secretHasher)
{
_userProvider = userProvider;
_secretHasher = secretHasher;
}
/// <inheritdoc />
public async ValueTask<User?> ValidateAsync(string username, string password, CancellationToken cancellationToken = default)
{
var user = await _userProvider.FindByNameAsync(username, cancellationToken);
if (user == null)
return null;
var isValidPassword = _secretHasher.VerifySecret(password, user.HashedPassword, user.HashedPasswordSalt);
return isValidPassword ? user : null;
}
}