Эх сурвалжийг харах

ChangePassword,InitialPassword

xf 2 жил өмнө
parent
commit
67c9d6878c

+ 23 - 0
src/Hotline.Api/Controllers/UserController.cs

@@ -262,6 +262,29 @@ public class UserController : BaseController
         return Task.FromResult(Convert.ToBoolean(claim.Value));
     }
 
+    /// <summary>
+    /// 修改密码
+    /// </summary>
+    /// <param name="dto"></param>
+    /// <returns></returns>
+    [HttpPost("change-pwd")]
+    public async Task ChangePassword([FromBody] UserChangePasswordDto dto)
+    {
+        var changepwdRsp = await _identityClient.ChangePasswordAsync(dto, HttpContext.RequestAborted);
+        CheckHttpRequestSuccess(changepwdRsp, "ChangePasswordAsync");
+    }
+
+    /// <summary>
+    /// 重置密码
+    /// </summary>
+    /// <returns></returns>
+    [HttpPost("initial-pwd/{userId}")]
+    public async Task InitialPassword(string userId)
+    {
+        var initpwdRsp = await _identityClient.InitialPasswordAsync(userId, HttpContext.RequestAborted);
+        CheckHttpRequestSuccess(initpwdRsp, "InitialPasswordAsync");
+    }
+
     #region private
 
     private async Task<bool> IsAccountLock(string userId)

+ 2 - 3
src/Hotline.Repository.SqlSugar/SqlSugarStartupExtensions.cs

@@ -145,11 +145,10 @@ namespace Hotline.Repository.SqlSugar
 
                         else if (entityInfo.EntityColumnInfo.IsPrimarykey
                                  && entityInfo.EntityColumnInfo.PropertyName.ToLower() == "id"
-                                 && entityInfo.OperationType == DataFilterType.InsertByObject
-                                 /*&& entityInfo.EntityValue is null*/) //通过主键保证只进一次事件
+                                 && entityInfo.OperationType == DataFilterType.InsertByObject) //通过主键保证只进一次事件
                         {
                             var propertyId = entityInfo.EntityValue.GetType().GetProperty("Id");
-                            if (propertyId != null)
+                            if (propertyId is not null)
                             {
                                 var idValue = propertyId.GetValue(entityInfo.EntityValue);
                                 if (idValue is null)