password rehashing

asp net identity v3 uses a new hashing algorithm (hmac-sha256)
This commit is contained in:
Spirtix 2025-06-26 18:06:29 +02:00
parent 0d6c8d6d47
commit f33d93e276

View File

@ -48,11 +48,15 @@ public class AuthenticationController : Controller {
} else {
user = ctx.Users.FirstOrDefault(e => e.Username == data.UserName);
}
if (user is null || new PasswordHasher<object>().VerifyHashedPassword(null, user.Password, data.Password) != PasswordVerificationResult.Success) {
PasswordVerificationResult result = new PasswordHasher<object>().VerifyHashedPassword(null, user.Password, data.Password);
if (user is null || result == PasswordVerificationResult.Failed) {
return Ok(new ParentLoginInfo { Status = MembershipUserStatus.InvalidPassword });
}
if (result == PasswordVerificationResult.SuccessRehashNeeded) {
user.Password = new PasswordHasher<object>().HashPassword(null, data.Password);
}
// Create session
Session session = new Session {
User = user,