fix: 修复授权配置复制功能,无法复制已加密字段的问题

This commit is contained in:
xiaojunnuo
2025-08-09 18:11:20 +08:00
parent 1bdceeecf4
commit 221e068bac
2 changed files with 26 additions and 1 deletions

View File

@@ -34,7 +34,18 @@ export class AccessService extends BaseService<AccessEntity> {
}
async add(param) {
this.encryptSetting(param, null);
let oldEntity = null;
if (param._copyFrom){
oldEntity = await this.info(param._copyFrom);
if (oldEntity == null) {
throw new ValidateException('该授权配置不存在,请确认是否已被删除');
}
if (oldEntity.userId !== param.userId) {
throw new ValidateException('您无权查看该授权配置');
}
}
delete param._copyFrom
this.encryptSetting(param, oldEntity);
return await super.add(param);
}