feat: SecureUtils 新增 decryptPasswordByRsaPrivateKey 方法统一处理密码解密

This commit is contained in:
2025-07-26 21:41:02 +08:00
parent 93bf749ce3
commit 1ec154f011
6 changed files with 50 additions and 47 deletions

View File

@@ -35,8 +35,6 @@ import top.continew.admin.tenant.model.req.TenantReq;
import top.continew.admin.tenant.model.resp.TenantDetailResp;
import top.continew.admin.tenant.model.resp.TenantResp;
import top.continew.admin.tenant.service.TenantService;
import top.continew.starter.core.util.ExceptionUtils;
import top.continew.starter.core.util.validation.ValidationUtils;
import top.continew.starter.extension.crud.annotation.CrudRequestMapping;
import top.continew.starter.extension.crud.enums.Api;
import top.continew.starter.extension.tenant.util.TenantUtils;
@@ -61,10 +59,8 @@ public class TenantController extends BaseController<TenantService, TenantResp,
@PutMapping("/{id}/admin/pwd")
public void updateAdminUserPwd(@Valid @RequestBody TenantAdminUserPwdUpdateReq req, @PathVariable Long id) {
TenantDO tenant = baseService.getById(id);
String encryptPassword = req.getPassword();
TenantUtils.execute(id, () -> {
String password = ExceptionUtils.exToNull(() -> SecureUtils.decryptByRsaPrivateKey(encryptPassword));
ValidationUtils.throwIfNull(password, "新密码解密失败");
String password = SecureUtils.decryptPasswordByRsaPrivateKey(req.getPassword(), "新密码解密失败");
userApi.resetPassword(password, tenant.getAdminUser());
});
}