@tomei/sso 0.49.1 → 0.50.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/src/components/system-privilege/system-privilege.d.ts +1 -0
- package/dist/src/components/system-privilege/system-privilege.js +41 -1
- package/dist/src/components/system-privilege/system-privilege.js.map +1 -1
- package/dist/src/components/system-privilege/system-privilege.repository.d.ts +1 -0
- package/dist/src/components/system-privilege/system-privilege.repository.js +17 -0
- package/dist/src/components/system-privilege/system-privilege.repository.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/components/system-privilege/system-privilege.repository.ts +7 -0
- package/src/components/system-privilege/system-privilege.ts +71 -1
package/package.json
CHANGED
@@ -8,4 +8,11 @@ export class SystemPrivilegeRepository
|
|
8
8
|
constructor() {
|
9
9
|
super(SystemPrivilege);
|
10
10
|
}
|
11
|
+
|
12
|
+
async delete(systemPrivilegeId: string, dbTransaction?: any) {
|
13
|
+
return await SystemPrivilege.destroy({
|
14
|
+
where: { SystemPrivilegeId: systemPrivilegeId },
|
15
|
+
transaction: dbTransaction,
|
16
|
+
});
|
17
|
+
}
|
11
18
|
}
|
@@ -213,7 +213,7 @@ export class SystemPrivilege extends ObjectBase {
|
|
213
213
|
activity.Action = ActionEnum.CREATE;
|
214
214
|
activity.Description = 'Add System Privilege';
|
215
215
|
activity.EntityType = 'SystemPrivilege';
|
216
|
-
activity.EntityId = newSystemPrivilege.
|
216
|
+
activity.EntityId = newSystemPrivilege.SystemPrivilegeId;
|
217
217
|
activity.EntityValueBefore = JSON.stringify(EntityValueBefore);
|
218
218
|
activity.EntityValueAfter = JSON.stringify(EntityValueAfter);
|
219
219
|
|
@@ -378,4 +378,74 @@ export class SystemPrivilege extends ObjectBase {
|
|
378
378
|
throw error;
|
379
379
|
}
|
380
380
|
}
|
381
|
+
|
382
|
+
public async delete(dbTransaction: any, loginUser: LoginUser) {
|
383
|
+
try {
|
384
|
+
//Part 1: Privilege Checking
|
385
|
+
const systemCode: string =
|
386
|
+
ApplicationConfig.getComponentConfigValue('system-code');
|
387
|
+
const isPrivileged = await loginUser.checkPrivileges(
|
388
|
+
systemCode,
|
389
|
+
'PRIVILEGE_DELETE',
|
390
|
+
);
|
391
|
+
if (!isPrivileged) {
|
392
|
+
throw new ClassError(
|
393
|
+
'SystemPrivilege',
|
394
|
+
'SystemPrivilegeErrMsg0X',
|
395
|
+
'You do not have permission to delete system privileges',
|
396
|
+
);
|
397
|
+
}
|
398
|
+
|
399
|
+
//Part 2: Validation
|
400
|
+
//Make sure SystemPrivilegeId is not empty
|
401
|
+
if (!this.SystemPrivilegeId) {
|
402
|
+
throw new ClassError(
|
403
|
+
'SystemPrivilege',
|
404
|
+
'SystemPrivilegeErrMsg02',
|
405
|
+
'System Privilege Id is required',
|
406
|
+
);
|
407
|
+
}
|
408
|
+
|
409
|
+
//Part 3: Delete Privilege
|
410
|
+
|
411
|
+
//Call SystemPrivilege._Repo delete method
|
412
|
+
await SystemPrivilege._Repository.delete(
|
413
|
+
this.SystemPrivilegeId,
|
414
|
+
dbTransaction,
|
415
|
+
);
|
416
|
+
|
417
|
+
//Part 4: Record Create Privilege Activity
|
418
|
+
//Initialise EntityValueBefore variable and set to empty object.
|
419
|
+
const EntityValueBefore = {
|
420
|
+
SystemPrivilegeId: this.ObjectId,
|
421
|
+
PrivilegeCode: this.PrivilegeCode,
|
422
|
+
SystemCode: this.SystemCode,
|
423
|
+
Description: this.Description,
|
424
|
+
Status: this.Status,
|
425
|
+
CreatedById: this._CreatedById,
|
426
|
+
UpdatedById: this._UpdatedById,
|
427
|
+
CreatedAt: this._CreatedAt,
|
428
|
+
UpdatedAt: this._UpdatedAt,
|
429
|
+
};
|
430
|
+
//Initialise EntityValueAfter variable and set to newSystemPrivilege object.
|
431
|
+
const EntityValueAfter = {};
|
432
|
+
|
433
|
+
//Instantiate new activity object and populate
|
434
|
+
const activity = new Activity();
|
435
|
+
activity.ActivityId = activity.createId();
|
436
|
+
activity.Action = ActionEnum.DELETE;
|
437
|
+
activity.Description = 'Delete System Privilege';
|
438
|
+
activity.EntityType = 'SystemPrivilege';
|
439
|
+
activity.EntityId = this.SystemPrivilegeId;
|
440
|
+
activity.EntityValueBefore = JSON.stringify(EntityValueBefore);
|
441
|
+
activity.EntityValueAfter = JSON.stringify(EntityValueAfter);
|
442
|
+
|
443
|
+
//Call Activity.create method
|
444
|
+
await activity.create(loginUser.ObjectId, dbTransaction);
|
445
|
+
|
446
|
+
return this;
|
447
|
+
} catch (error) {
|
448
|
+
throw error;
|
449
|
+
}
|
450
|
+
}
|
381
451
|
}
|