Fix not resolving IPasswordHasher

This commit is contained in:
2025-11-01 20:41:21 +09:00
parent e7f646c408
commit 7cfabe0af2

View File

@ -1,7 +1,6 @@
using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Identity.EntityFrameworkCore; using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
namespace Hcs.WebApp.Data.Identity namespace Hcs.WebApp.Data.Identity
{ {
@ -57,7 +56,7 @@ namespace Hcs.WebApp.Data.Identity
LockoutEnabled = true LockoutEnabled = true
}; };
var passwordHasher = context.GetService<IPasswordHasher<AppUser>>(); var passwordHasher = new PasswordHasher<AppUser>();
adminUser.PasswordHash = passwordHasher.HashPassword(adminUser, AppUser.ADMINISTRATOR_PASSWORD); adminUser.PasswordHash = passwordHasher.HashPassword(adminUser, AppUser.ADMINISTRATOR_PASSWORD);
var entry = context.Set<AppUser>().Add(adminUser); var entry = context.Set<AppUser>().Add(adminUser);
@ -120,7 +119,7 @@ namespace Hcs.WebApp.Data.Identity
LockoutEnabled = true LockoutEnabled = true
}; };
var passwordHasher = context.GetService<IPasswordHasher<AppUser>>(); var passwordHasher = new PasswordHasher<AppUser>();
adminUser.PasswordHash = passwordHasher.HashPassword(adminUser, AppUser.ADMINISTRATOR_PASSWORD); adminUser.PasswordHash = passwordHasher.HashPassword(adminUser, AppUser.ADMINISTRATOR_PASSWORD);
var entry = context.Set<AppUser>().Add(adminUser); var entry = context.Set<AppUser>().Add(adminUser);