@tomei/sso 0.32.2 → 0.32.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/components/group/group.d.ts +3 -0
- package/dist/src/components/group/group.js +53 -0
- package/dist/src/components/group/group.js.map +1 -1
- package/dist/src/components/group-system-access/group-system-access.d.ts +4 -0
- package/dist/src/components/group-system-access/group-system-access.js +12 -0
- package/dist/src/components/group-system-access/group-system-access.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/components/group/group.ts +89 -0
- package/src/components/group-system-access/group-system-access.ts +15 -0
package/package.json
CHANGED
|
@@ -9,6 +9,7 @@ import { Op } from 'sequelize';
|
|
|
9
9
|
import { ActionEnum, Activity } from '@tomei/activity-history';
|
|
10
10
|
import { GroupSystemAccessRepository } from '../group-system-access/group-system-access.repository';
|
|
11
11
|
import SystemModel from '../../models/system.entity';
|
|
12
|
+
import { GroupSystemAccess } from 'components/group-system-access';
|
|
12
13
|
|
|
13
14
|
export class Group extends ObjectBase {
|
|
14
15
|
ObjectId: string;
|
|
@@ -584,4 +585,92 @@ export class Group extends ObjectBase {
|
|
|
584
585
|
throw error;
|
|
585
586
|
}
|
|
586
587
|
}
|
|
588
|
+
|
|
589
|
+
public static async addSystemAccesses(
|
|
590
|
+
loginUser: LoginUser,
|
|
591
|
+
dbTransaction: any,
|
|
592
|
+
GroupCode: string,
|
|
593
|
+
SystemCodes: string[],
|
|
594
|
+
) {
|
|
595
|
+
// Part 1: Privilege Checking
|
|
596
|
+
const systemCode = ApplicationConfig.getComponentConfigValue('system-code');
|
|
597
|
+
const isPrivileged = await loginUser.checkPrivileges(
|
|
598
|
+
systemCode,
|
|
599
|
+
'SYSTEM_ACCESS_CREATE',
|
|
600
|
+
);
|
|
601
|
+
|
|
602
|
+
if (!isPrivileged) {
|
|
603
|
+
throw new ClassError(
|
|
604
|
+
'Group',
|
|
605
|
+
'GroupErrMsg07',
|
|
606
|
+
'You do not have the privilege to create system access',
|
|
607
|
+
);
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
try {
|
|
611
|
+
if (SystemCodes.length > 0) {
|
|
612
|
+
for (let i = 0; i < SystemCodes.length; i++) {
|
|
613
|
+
const CurrentGroupSystemAccess = Group.getSystemAccesses(
|
|
614
|
+
loginUser,
|
|
615
|
+
dbTransaction,
|
|
616
|
+
GroupCode,
|
|
617
|
+
1,
|
|
618
|
+
Number.MAX_SAFE_INTEGER,
|
|
619
|
+
{ SystemCode: SystemCodes[i] },
|
|
620
|
+
);
|
|
621
|
+
console.log(CurrentGroupSystemAccess);
|
|
622
|
+
|
|
623
|
+
// if (false) {
|
|
624
|
+
// throw new ClassError(
|
|
625
|
+
// 'Group',
|
|
626
|
+
// 'GroupErrMsg08',
|
|
627
|
+
// 'System access already exists',
|
|
628
|
+
// );
|
|
629
|
+
// }
|
|
630
|
+
|
|
631
|
+
const groupSystemAccess = await GroupSystemAccess.init(dbTransaction);
|
|
632
|
+
groupSystemAccess.createId();
|
|
633
|
+
groupSystemAccess.GroupCode = GroupCode;
|
|
634
|
+
groupSystemAccess.SystemCode = GroupCode;
|
|
635
|
+
groupSystemAccess.Status = 'Active';
|
|
636
|
+
groupSystemAccess.CreatedById = +loginUser.ObjectId;
|
|
637
|
+
groupSystemAccess.CreatedAt = new Date();
|
|
638
|
+
groupSystemAccess.UpdatedById = +loginUser.ObjectId;
|
|
639
|
+
groupSystemAccess.UpdatedAt = new Date();
|
|
640
|
+
|
|
641
|
+
const EntityValueAfter = {
|
|
642
|
+
GroupCode: groupSystemAccess.GroupCode,
|
|
643
|
+
SystemCode: groupSystemAccess.SystemCode,
|
|
644
|
+
Status: groupSystemAccess.Status,
|
|
645
|
+
CreatedById: groupSystemAccess.CreatedById,
|
|
646
|
+
CreatedAt: groupSystemAccess.CreatedAt,
|
|
647
|
+
UpdatedById: groupSystemAccess.UpdatedById,
|
|
648
|
+
UpdatedAt: groupSystemAccess.UpdatedAt,
|
|
649
|
+
};
|
|
650
|
+
|
|
651
|
+
const systemAccess = await Group._SystemAccessRepo.create(
|
|
652
|
+
EntityValueAfter,
|
|
653
|
+
{
|
|
654
|
+
transaction: dbTransaction,
|
|
655
|
+
},
|
|
656
|
+
);
|
|
657
|
+
|
|
658
|
+
const activity = new Activity();
|
|
659
|
+
activity.ActivityId = activity.createId();
|
|
660
|
+
activity.Action = ActionEnum.ADD;
|
|
661
|
+
activity.Description = 'Create Group System Access';
|
|
662
|
+
activity.EntityType = 'GroupSystemAccess';
|
|
663
|
+
activity.EntityId = systemAccess.GroupSystemAccessId?.toString();
|
|
664
|
+
activity.EntityValueBefore = JSON.stringify({});
|
|
665
|
+
activity.EntityValueAfter = JSON.stringify(EntityValueAfter);
|
|
666
|
+
|
|
667
|
+
await activity.create(loginUser.ObjectId, dbTransaction);
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
return { Message: 'Successfully added.' };
|
|
671
|
+
}
|
|
672
|
+
} catch (error) {
|
|
673
|
+
throw error;
|
|
674
|
+
}
|
|
675
|
+
}
|
|
587
676
|
}
|
|
@@ -20,19 +20,34 @@ export class GroupSystemAccess extends ObjectBase {
|
|
|
20
20
|
get CreatedAt() {
|
|
21
21
|
return this._CreatedAt;
|
|
22
22
|
}
|
|
23
|
+
set CreatedAt(CreatedAt: Date) {
|
|
24
|
+
this._CreatedAt = CreatedAt;
|
|
25
|
+
}
|
|
23
26
|
|
|
24
27
|
get UpdatedAt() {
|
|
25
28
|
return this._UpdatedAt;
|
|
26
29
|
}
|
|
27
30
|
|
|
31
|
+
set UpdatedAt(UpdatedAt: Date) {
|
|
32
|
+
this._UpdatedAt = UpdatedAt;
|
|
33
|
+
}
|
|
34
|
+
|
|
28
35
|
get CreatedById() {
|
|
29
36
|
return this._CreatedById;
|
|
30
37
|
}
|
|
31
38
|
|
|
39
|
+
set CreatedById(CreatedById: number) {
|
|
40
|
+
this._CreatedById = CreatedById;
|
|
41
|
+
}
|
|
42
|
+
|
|
32
43
|
get UpdatedById() {
|
|
33
44
|
return this._UpdatedById;
|
|
34
45
|
}
|
|
35
46
|
|
|
47
|
+
set UpdatedById(UpdatedById: number) {
|
|
48
|
+
this._UpdatedById = UpdatedById;
|
|
49
|
+
}
|
|
50
|
+
|
|
36
51
|
private static _Repository = new GroupSystemAccessRepository();
|
|
37
52
|
|
|
38
53
|
constructor(groupSystemAccessAttr?: IGroupSystemAccessAttr) {
|