mirror of
https://github.com/certd/certd.git
synced 2026-04-23 19:57:27 +08:00
chore:
This commit is contained in:
@@ -37,22 +37,19 @@ export class HandleController extends BaseController {
|
||||
//@ts-ignore
|
||||
const access = new accessCls();
|
||||
|
||||
let isNew = true;
|
||||
let inputAccess = body.input.access;
|
||||
if (body.input.id > 0) {
|
||||
const oldEntity = await this.accessService.info(body.input.id);
|
||||
if (!oldEntity) {
|
||||
isNew = false;
|
||||
const param = {
|
||||
if (oldEntity) {
|
||||
const param: any = {
|
||||
type: body.typeName,
|
||||
setting: JSON.stringify(body.input.access),
|
||||
};
|
||||
this.accessService.encryptSetting(param, oldEntity);
|
||||
body.input.access = JSON.parse(param.setting);
|
||||
inputAccess = this.accessService.decryptAccessEntity(param);
|
||||
}
|
||||
}
|
||||
if (isNew) {
|
||||
mergeUtils.merge(access, body.input.access);
|
||||
}
|
||||
mergeUtils.merge(access, inputAccess);
|
||||
|
||||
const ctx: AccessRequestHandleContext = {
|
||||
http: http,
|
||||
|
||||
@@ -108,6 +108,14 @@ export class AccessService extends BaseService<AccessEntity> implements IAccessS
|
||||
throw new Error(`该授权配置不存在,请确认是否已被删除:id=${id}`);
|
||||
}
|
||||
// const access = accessRegistry.get(entity.type);
|
||||
const setting = this.decryptAccessEntity(entity);
|
||||
return {
|
||||
id: entity.id,
|
||||
...setting,
|
||||
};
|
||||
}
|
||||
|
||||
decryptAccessEntity(entity: AccessEntity): any {
|
||||
let setting = {};
|
||||
if (entity.encryptSetting && entity.encryptSetting !== '{}') {
|
||||
setting = JSON.parse(entity.encryptSetting);
|
||||
@@ -123,10 +131,7 @@ export class AccessService extends BaseService<AccessEntity> implements IAccessS
|
||||
} else if (entity.setting) {
|
||||
setting = JSON.parse(entity.setting);
|
||||
}
|
||||
return {
|
||||
id: entity.id,
|
||||
...setting,
|
||||
};
|
||||
return setting;
|
||||
}
|
||||
|
||||
getDefineList() {
|
||||
|
||||
Reference in New Issue
Block a user