feat 增加密码重置功能

This commit is contained in:
2024-07-17 10:47:06 +08:00
parent b8708d36f1
commit 66c24e2ebe
4 changed files with 34 additions and 0 deletions

View File

@@ -158,4 +158,19 @@ public class UserService : IUserService
.Where(x => x.ClaimType == "tenants")
.ExecuteCommandAsync();
}
/// <inheritdoc />
public async Task ResetPasswordAsync(UserResetPasswordRequest request)
{
request.Password ??= "123456";
var user = await _identityDbContext.Queryable<UserEntity>().SingleAsync(x => x.Id == request.UserId);
if (user != null)
{
var hasher = new PasswordHasher<UserEntity>();
var password = hasher.HashPassword(user, request.Password);
user.PasswordHash = password;
await _identityDbContext.UpdateAsync(user);
}
}
}