using Microsoft.AspNetCore.Identity; using System.Numerics; using DeluxeBackend.Models; namespace DeluxeBackend.Services { public interface IPasswordService { void setPassword(Account player, string password); PasswordVerificationResult VerifyPassword(Account player, string passowrd); } public class PasswordService : IPasswordService { private readonly ILiteDbService db; private readonly PasswordHasher _hasher = new PasswordHasher(); public PasswordService(ILiteDbService _db) { db = _db; } public void setPassword(Account player, string password) { player.PasswordHash = _hasher.HashPassword(player, password); db.Accounts.Update(player); } public PasswordVerificationResult VerifyPassword(Account player, string passowrd) { if (player.PasswordHash == null) { return PasswordVerificationResult.Failed; } return _hasher.VerifyHashedPassword(player, player.PasswordHash, passowrd); } } }