using Infrastructure.PasswordHashing;
using Microsoft.AspNetCore.Identity;
namespace Features.Auth.Identity;
/// Adapts 's Argon2 hashing to .
public sealed class Argon2PasswordHasher(IPasswordInfrastructure passwordInfrastructure)
: IPasswordHasher
{
///
public string HashPassword(ApplicationUser user, string password) =>
passwordInfrastructure.Hash(password);
///
///
/// Never returns : Argon2 parameters are
/// fixed by , so 's automatic
/// rehash-on-verify path never triggers.
///
public PasswordVerificationResult VerifyHashedPassword(
ApplicationUser user,
string hashedPassword,
string providedPassword
) =>
passwordInfrastructure.Verify(providedPassword, hashedPassword)
? PasswordVerificationResult.Success
: PasswordVerificationResult.Failed;
}