diff --git a/Src/Dlhis.Sys/Identity/Controllers/UsersController.cs b/Src/Dlhis.Sys/Identity/Controllers/UsersController.cs
index c0b35b98..5232aa00 100644
--- a/Src/Dlhis.Sys/Identity/Controllers/UsersController.cs
+++ b/Src/Dlhis.Sys/Identity/Controllers/UsersController.cs
@@ -98,4 +98,14 @@ public class UsersController : ControllerBase
{
await _userService.ResetLoginTenantAsync(request);
}
+
+ ///
+ /// 密码重置
+ ///
+ ///
+ [HttpPost("password/reset")]
+ public async Task ResetPasswordAsync(UserResetPasswordRequest request)
+ {
+ await _userService.ResetPasswordAsync(request);
+ }
}
\ No newline at end of file
diff --git a/Src/Dlhis.Sys/Identity/Request/UserResetPasswordRequest.cs b/Src/Dlhis.Sys/Identity/Request/UserResetPasswordRequest.cs
new file mode 100644
index 00000000..9319650a
--- /dev/null
+++ b/Src/Dlhis.Sys/Identity/Request/UserResetPasswordRequest.cs
@@ -0,0 +1,7 @@
+namespace Dlhis.Sys.Identity.Request;
+
+public class UserResetPasswordRequest
+{
+ public int UserId { get; set; }
+ public string Password { get; set; }
+}
\ No newline at end of file
diff --git a/Src/Dlhis.Sys/Identity/Services/IUserService.cs b/Src/Dlhis.Sys/Identity/Services/IUserService.cs
index 84c069e7..6f114ba3 100644
--- a/Src/Dlhis.Sys/Identity/Services/IUserService.cs
+++ b/Src/Dlhis.Sys/Identity/Services/IUserService.cs
@@ -22,4 +22,6 @@ public interface IUserService : IScopeDependency
Task CreateUserAsync(UserCreateRequest request);
Task ResetLoginTenantAsync(UserResetLoginTenantRequest request);
+
+ Task ResetPasswordAsync(UserResetPasswordRequest request);
}
\ No newline at end of file
diff --git a/Src/Dlhis.Sys/Identity/Services/Implements/UserService.cs b/Src/Dlhis.Sys/Identity/Services/Implements/UserService.cs
index 17f9e5cb..6525ca36 100644
--- a/Src/Dlhis.Sys/Identity/Services/Implements/UserService.cs
+++ b/Src/Dlhis.Sys/Identity/Services/Implements/UserService.cs
@@ -158,4 +158,19 @@ public class UserService : IUserService
.Where(x => x.ClaimType == "tenants")
.ExecuteCommandAsync();
}
+
+ ///
+ public async Task ResetPasswordAsync(UserResetPasswordRequest request)
+ {
+ request.Password ??= "123456";
+ var user = await _identityDbContext.Queryable().SingleAsync(x => x.Id == request.UserId);
+ if (user != null)
+ {
+ var hasher = new PasswordHasher();
+ var password = hasher.HashPassword(user, request.Password);
+ user.PasswordHash = password;
+
+ await _identityDbContext.UpdateAsync(user);
+ }
+ }
}
\ No newline at end of file