@tomei/sso 0.33.8 → 0.34.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/src/components/group/group.js +24 -18
- package/dist/src/components/group/group.js.map +1 -1
- package/dist/src/components/group-object-privilege/group-object-privilege.js +4 -2
- package/dist/src/components/group-object-privilege/group-object-privilege.js.map +1 -1
- package/dist/src/components/group-object-privilege/group-object-privilege.repository.js.map +1 -1
- package/dist/src/components/group-privilege/group-privilege.repository.js.map +1 -1
- package/dist/src/components/system-privilege/system-privilege.js +1 -1
- package/dist/src/components/system-privilege/system-privilege.js.map +1 -1
- package/dist/src/components/user-object-privilege/user-object-privilege.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/components/group/group.ts +1485 -1456
- package/src/components/group-object-privilege/group-object-privilege.repository.ts +3 -2
- package/src/components/group-object-privilege/group-object-privilege.ts +44 -31
- package/src/components/group-privilege/group-privilege.repository.ts +2 -1
- package/src/components/system-privilege/system-privilege.ts +7 -4
- package/src/components/user-object-privilege/user-object-privilege.ts +0 -1
- package/src/interfaces/group-object-privilege.interface.ts +14 -14
- package/src/interfaces/system-privilege-search.interface.ts +5 -5
- package/src/models/group-system-access.entity.ts +81 -81
@@ -3,14 +3,15 @@ import { RepositoryBase, IRepositoryBase } from '@tomei/general';
|
|
3
3
|
|
4
4
|
export class GroupObjectPrivilegeRepository
|
5
5
|
extends RepositoryBase<GroupObjectPrivilegeModel>
|
6
|
-
implements IRepositoryBase<GroupObjectPrivilegeModel>
|
6
|
+
implements IRepositoryBase<GroupObjectPrivilegeModel>
|
7
|
+
{
|
7
8
|
constructor() {
|
8
9
|
super(GroupObjectPrivilegeModel);
|
9
10
|
}
|
10
11
|
|
11
12
|
public async delete(
|
12
13
|
where: any,
|
13
|
-
transaction?: any
|
14
|
+
transaction?: any,
|
14
15
|
): Promise<number | undefined> {
|
15
16
|
try {
|
16
17
|
return await GroupObjectPrivilegeModel.destroy({
|
@@ -83,10 +83,15 @@ export class GroupObjectPrivilege extends ObjectBase {
|
|
83
83
|
}
|
84
84
|
}
|
85
85
|
|
86
|
-
public static async create(
|
86
|
+
public static async create(
|
87
|
+
loginUser: LoginUser,
|
88
|
+
dbTransaction: any,
|
89
|
+
groupObjectPrivilege: GroupObjectPrivilege,
|
90
|
+
) {
|
87
91
|
try {
|
88
92
|
// Part 1: Privilege Checking
|
89
|
-
const systemCode =
|
93
|
+
const systemCode =
|
94
|
+
ApplicationConfig.getComponentConfigValue('system-code');
|
90
95
|
const isPrivileged = await loginUser.checkPrivileges(
|
91
96
|
systemCode,
|
92
97
|
'GROUP_OBJECT_PRIVILEGE_CREATE',
|
@@ -100,7 +105,6 @@ export class GroupObjectPrivilege extends ObjectBase {
|
|
100
105
|
);
|
101
106
|
}
|
102
107
|
|
103
|
-
|
104
108
|
// Part 2: Validation
|
105
109
|
// Make sure below variables exists:
|
106
110
|
// Params.groupObjectPrivilege.GroupCode
|
@@ -137,15 +141,16 @@ export class GroupObjectPrivilege extends ObjectBase {
|
|
137
141
|
}
|
138
142
|
|
139
143
|
// Call GroupObjectPrivilege._Repo findOne
|
140
|
-
const existingGroupObjectPrivilege =
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
144
|
+
const existingGroupObjectPrivilege =
|
145
|
+
await GroupObjectPrivilege._Repository.findOne({
|
146
|
+
where: {
|
147
|
+
GroupCode: groupObjectPrivilege.GroupCode,
|
148
|
+
PrivilegeCode: groupObjectPrivilege.PrivilegeCode,
|
149
|
+
ObjectId: groupObjectPrivilege.ObjectId,
|
150
|
+
ObjectType: groupObjectPrivilege.ObjectType,
|
151
|
+
},
|
152
|
+
transaction: dbTransaction,
|
153
|
+
});
|
149
154
|
|
150
155
|
// If GroupObjectPrivilege found, throw new ClassError
|
151
156
|
if (existingGroupObjectPrivilege) {
|
@@ -172,27 +177,31 @@ export class GroupObjectPrivilege extends ObjectBase {
|
|
172
177
|
const newGroupObjectPrivilege = new GroupObjectPrivilege(objectAttr);
|
173
178
|
|
174
179
|
// Call GroupObjectPrivilege._Repo create method
|
175
|
-
const createdObject = await GroupObjectPrivilege._Repository.create(
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
+
const createdObject = await GroupObjectPrivilege._Repository.create(
|
181
|
+
newGroupObjectPrivilege,
|
182
|
+
{
|
183
|
+
transaction: dbTransaction,
|
184
|
+
},
|
185
|
+
);
|
186
|
+
newGroupObjectPrivilege.GroupObjectPrivilegeId =
|
187
|
+
createdObject.GroupObjectPrivilegeId;
|
180
188
|
|
181
189
|
// Part 4: Record Create Group Activity
|
182
|
-
// Initialise
|
190
|
+
// Initialise EntityValueBefore variable and set to empty object.
|
183
191
|
const EntityValueBefore = {};
|
184
|
-
// Initialise
|
192
|
+
// Initialise EntityValueAfter variable and set to new Group instance in Part 3.
|
185
193
|
const EntityValueAfter = objectAttr;
|
186
|
-
// Instantiate new activity from
|
194
|
+
// Instantiate new activity from Activity class
|
187
195
|
const activity = new Activity();
|
188
196
|
activity.createId();
|
189
197
|
activity.Action = ActionEnum.ADD;
|
190
198
|
activity.Description = `Create GroupObjectPrivilege for (${newGroupObjectPrivilege.GroupCode})`;
|
191
199
|
activity.EntityType = 'GroupObjectPrivilege';
|
192
|
-
activity.EntityId =
|
200
|
+
activity.EntityId =
|
201
|
+
newGroupObjectPrivilege.GroupObjectPrivilegeId.toString();
|
193
202
|
activity.EntityValueBefore = JSON.stringify(EntityValueBefore);
|
194
203
|
activity.EntityValueAfter = JSON.stringify(EntityValueAfter);
|
195
|
-
// Call new activity create method.Make sure to pass the
|
204
|
+
// Call new activity create method.Make sure to pass the dbTransaction and loginUser.userId.
|
196
205
|
await activity.create(dbTransaction, loginUser.UserId);
|
197
206
|
|
198
207
|
// Return new Group instance
|
@@ -205,7 +214,8 @@ export class GroupObjectPrivilege extends ObjectBase {
|
|
205
214
|
public async delete(loginUser: LoginUser, dbTransaction: any) {
|
206
215
|
try {
|
207
216
|
//Part 1: Privilege Checking
|
208
|
-
const systemCode =
|
217
|
+
const systemCode =
|
218
|
+
ApplicationConfig.getComponentConfigValue('system-code');
|
209
219
|
const isPrivileged = await loginUser.checkPrivileges(
|
210
220
|
systemCode,
|
211
221
|
'GROUP_OBJECT_PRIVILEGE_DELETE',
|
@@ -224,12 +234,15 @@ export class GroupObjectPrivilege extends ObjectBase {
|
|
224
234
|
// dbTransaction
|
225
235
|
// GroupObjectPrivilege: this.GroupObjectPrivilegeId
|
226
236
|
|
227
|
-
await GroupObjectPrivilege._Repository.delete(
|
228
|
-
|
229
|
-
|
237
|
+
await GroupObjectPrivilege._Repository.delete(
|
238
|
+
this.GroupObjectPrivilegeId,
|
239
|
+
{
|
240
|
+
transaction: dbTransaction,
|
241
|
+
},
|
242
|
+
);
|
230
243
|
|
231
244
|
// Part 4: Record Create Group Activity
|
232
|
-
// Initialise
|
245
|
+
// Initialise EntityValueBefore variable and set GroupObjectPrivelege column properties
|
233
246
|
const EntityValueBefore = {
|
234
247
|
GroupCode: this.GroupCode,
|
235
248
|
PrivilegeCode: this.PrivilegeCode,
|
@@ -240,10 +253,10 @@ export class GroupObjectPrivilege extends ObjectBase {
|
|
240
253
|
UpdatedById: this.UpdatedById,
|
241
254
|
};
|
242
255
|
|
243
|
-
// Initialise
|
256
|
+
// Initialise EntityValueAfter variable and set empty object
|
244
257
|
const EntityValueAfter = {};
|
245
|
-
|
246
|
-
// Instantiate new activity from
|
258
|
+
|
259
|
+
// Instantiate new activity from Activity class
|
247
260
|
const activity = new Activity();
|
248
261
|
activity.createId();
|
249
262
|
activity.Action = ActionEnum.DELETE;
|
@@ -253,7 +266,7 @@ export class GroupObjectPrivilege extends ObjectBase {
|
|
253
266
|
activity.EntityValueBefore = JSON.stringify(EntityValueBefore);
|
254
267
|
activity.EntityValueAfter = JSON.stringify(EntityValueAfter);
|
255
268
|
|
256
|
-
// Call new activity create method.Make sure to pass the
|
269
|
+
// Call new activity create method.Make sure to pass the dbTransaction and LoginUser.userId.
|
257
270
|
await activity.create(dbTransaction, loginUser.UserId);
|
258
271
|
|
259
272
|
// Return this
|
@@ -3,7 +3,8 @@ import { RepositoryBase, IRepositoryBase } from '@tomei/general';
|
|
3
3
|
|
4
4
|
export class GroupPrivilegeRepository
|
5
5
|
extends RepositoryBase<GroupPrivilegeModel>
|
6
|
-
implements IRepositoryBase<GroupPrivilegeModel>
|
6
|
+
implements IRepositoryBase<GroupPrivilegeModel>
|
7
|
+
{
|
7
8
|
constructor() {
|
8
9
|
super(GroupPrivilegeModel);
|
9
10
|
}
|
@@ -227,7 +227,8 @@ export class SystemPrivilege extends ObjectBase {
|
|
227
227
|
) {
|
228
228
|
try {
|
229
229
|
// Part 1: Privilege Checking
|
230
|
-
const systemCode =
|
230
|
+
const systemCode =
|
231
|
+
ApplicationConfig.getComponentConfigValue('system-code');
|
231
232
|
const isPrivileged = await loginUser.checkPrivileges(
|
232
233
|
systemCode,
|
233
234
|
'PRIVILEGE_LIST',
|
@@ -242,7 +243,7 @@ export class SystemPrivilege extends ObjectBase {
|
|
242
243
|
}
|
243
244
|
|
244
245
|
// Part 2: Retrieve listing
|
245
|
-
|
246
|
+
const options: any = {
|
246
247
|
order: [['createdAt', 'DESC']],
|
247
248
|
transaction: dbTransaction,
|
248
249
|
};
|
@@ -255,7 +256,7 @@ export class SystemPrivilege extends ObjectBase {
|
|
255
256
|
options.limit = limit;
|
256
257
|
}
|
257
258
|
|
258
|
-
//If search query exists, please set it to sequelize
|
259
|
+
//If search query exists, please set it to sequelize where option.
|
259
260
|
if (search) {
|
260
261
|
const queryObj: any = {};
|
261
262
|
Object.entries(search).forEach(([key, value]) => {
|
@@ -267,7 +268,9 @@ export class SystemPrivilege extends ObjectBase {
|
|
267
268
|
options.where = queryObj;
|
268
269
|
}
|
269
270
|
|
270
|
-
const result = await SystemPrivilege._Repository.findAllWithPagination(
|
271
|
+
const result = await SystemPrivilege._Repository.findAllWithPagination(
|
272
|
+
options,
|
273
|
+
);
|
271
274
|
|
272
275
|
// Part 3: Return result
|
273
276
|
// Map the result to SystemPrivilege object
|
@@ -1,14 +1,14 @@
|
|
1
|
-
import { ObjectStatus } from '../enum/object-status.enum';
|
2
|
-
|
3
|
-
export interface IGroupObjectPrivilegeAttr {
|
4
|
-
GroupObjectPrivilegeId?: number;
|
5
|
-
GroupCode: string;
|
6
|
-
PrivilegeCode: string;
|
7
|
-
ObjectId: string;
|
8
|
-
ObjectType: string;
|
9
|
-
Status: ObjectStatus;
|
10
|
-
CreatedById: number;
|
11
|
-
UpdatedById: number;
|
12
|
-
CreatedAt: Date;
|
13
|
-
UpdatedAt: Date;
|
14
|
-
}
|
1
|
+
import { ObjectStatus } from '../enum/object-status.enum';
|
2
|
+
|
3
|
+
export interface IGroupObjectPrivilegeAttr {
|
4
|
+
GroupObjectPrivilegeId?: number;
|
5
|
+
GroupCode: string;
|
6
|
+
PrivilegeCode: string;
|
7
|
+
ObjectId: string;
|
8
|
+
ObjectType: string;
|
9
|
+
Status: ObjectStatus;
|
10
|
+
CreatedById: number;
|
11
|
+
UpdatedById: number;
|
12
|
+
CreatedAt: Date;
|
13
|
+
UpdatedAt: Date;
|
14
|
+
}
|
@@ -1,5 +1,5 @@
|
|
1
|
-
export interface ISystemPrivilegeSearch {
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
}
|
1
|
+
export interface ISystemPrivilegeSearch {
|
2
|
+
PrivilegeCode?: string;
|
3
|
+
SystemCode?: string;
|
4
|
+
Status?: string;
|
5
|
+
}
|
@@ -1,81 +1,81 @@
|
|
1
|
-
import {
|
2
|
-
BelongsTo,
|
3
|
-
Column,
|
4
|
-
CreatedAt,
|
5
|
-
DataType,
|
6
|
-
ForeignKey,
|
7
|
-
Model,
|
8
|
-
Table,
|
9
|
-
UpdatedAt,
|
10
|
-
} from 'sequelize-typescript';
|
11
|
-
import User from './user.entity';
|
12
|
-
import GroupModel from './group.entity';
|
13
|
-
import SystemModel from './system.entity';
|
14
|
-
|
15
|
-
@Table({
|
16
|
-
tableName: 'sso_GroupSystemAccess',
|
17
|
-
timestamps: true,
|
18
|
-
createdAt: 'CreatedAt',
|
19
|
-
updatedAt: 'UpdatedAt',
|
20
|
-
})
|
21
|
-
export default class GroupSystemAccessModel extends Model {
|
22
|
-
@Column({
|
23
|
-
autoIncrement: true,
|
24
|
-
primaryKey: true,
|
25
|
-
allowNull: false,
|
26
|
-
type: DataType.INTEGER,
|
27
|
-
})
|
28
|
-
GroupSystemAccessId: number;
|
29
|
-
|
30
|
-
@ForeignKey(() => GroupModel)
|
31
|
-
@Column({
|
32
|
-
allowNull: false,
|
33
|
-
type: DataType.STRING(10),
|
34
|
-
})
|
35
|
-
GroupCode: string;
|
36
|
-
|
37
|
-
@ForeignKey(() => SystemModel)
|
38
|
-
@Column({
|
39
|
-
allowNull: false,
|
40
|
-
type: DataType.STRING(10),
|
41
|
-
})
|
42
|
-
SystemCode: string;
|
43
|
-
|
44
|
-
@Column({
|
45
|
-
allowNull: false,
|
46
|
-
type: DataType.CHAR(10),
|
47
|
-
})
|
48
|
-
Status: string;
|
49
|
-
|
50
|
-
@ForeignKey(() => User)
|
51
|
-
@Column({
|
52
|
-
allowNull: false,
|
53
|
-
type: DataType.INTEGER,
|
54
|
-
})
|
55
|
-
CreatedById: number;
|
56
|
-
|
57
|
-
@ForeignKey(() => User)
|
58
|
-
@Column({
|
59
|
-
allowNull: false,
|
60
|
-
type: DataType.INTEGER,
|
61
|
-
})
|
62
|
-
UpdatedById: number;
|
63
|
-
|
64
|
-
@CreatedAt
|
65
|
-
CreatedAt: Date;
|
66
|
-
|
67
|
-
@UpdatedAt
|
68
|
-
UpdatedAt: Date;
|
69
|
-
|
70
|
-
@BelongsTo(() => User, 'CreatedById')
|
71
|
-
CreatedByUser: User;
|
72
|
-
|
73
|
-
@BelongsTo(() => User, 'UpdatedById')
|
74
|
-
UpdatedByUser: User;
|
75
|
-
|
76
|
-
@BelongsTo(() => SystemModel, 'SystemCode')
|
77
|
-
System: SystemModel;
|
78
|
-
|
79
|
-
@BelongsTo(() => GroupModel, 'GroupCode')
|
80
|
-
Group: GroupModel;
|
81
|
-
}
|
1
|
+
import {
|
2
|
+
BelongsTo,
|
3
|
+
Column,
|
4
|
+
CreatedAt,
|
5
|
+
DataType,
|
6
|
+
ForeignKey,
|
7
|
+
Model,
|
8
|
+
Table,
|
9
|
+
UpdatedAt,
|
10
|
+
} from 'sequelize-typescript';
|
11
|
+
import User from './user.entity';
|
12
|
+
import GroupModel from './group.entity';
|
13
|
+
import SystemModel from './system.entity';
|
14
|
+
|
15
|
+
@Table({
|
16
|
+
tableName: 'sso_GroupSystemAccess',
|
17
|
+
timestamps: true,
|
18
|
+
createdAt: 'CreatedAt',
|
19
|
+
updatedAt: 'UpdatedAt',
|
20
|
+
})
|
21
|
+
export default class GroupSystemAccessModel extends Model {
|
22
|
+
@Column({
|
23
|
+
autoIncrement: true,
|
24
|
+
primaryKey: true,
|
25
|
+
allowNull: false,
|
26
|
+
type: DataType.INTEGER,
|
27
|
+
})
|
28
|
+
GroupSystemAccessId: number;
|
29
|
+
|
30
|
+
@ForeignKey(() => GroupModel)
|
31
|
+
@Column({
|
32
|
+
allowNull: false,
|
33
|
+
type: DataType.STRING(10),
|
34
|
+
})
|
35
|
+
GroupCode: string;
|
36
|
+
|
37
|
+
@ForeignKey(() => SystemModel)
|
38
|
+
@Column({
|
39
|
+
allowNull: false,
|
40
|
+
type: DataType.STRING(10),
|
41
|
+
})
|
42
|
+
SystemCode: string;
|
43
|
+
|
44
|
+
@Column({
|
45
|
+
allowNull: false,
|
46
|
+
type: DataType.CHAR(10),
|
47
|
+
})
|
48
|
+
Status: string;
|
49
|
+
|
50
|
+
@ForeignKey(() => User)
|
51
|
+
@Column({
|
52
|
+
allowNull: false,
|
53
|
+
type: DataType.INTEGER,
|
54
|
+
})
|
55
|
+
CreatedById: number;
|
56
|
+
|
57
|
+
@ForeignKey(() => User)
|
58
|
+
@Column({
|
59
|
+
allowNull: false,
|
60
|
+
type: DataType.INTEGER,
|
61
|
+
})
|
62
|
+
UpdatedById: number;
|
63
|
+
|
64
|
+
@CreatedAt
|
65
|
+
CreatedAt: Date;
|
66
|
+
|
67
|
+
@UpdatedAt
|
68
|
+
UpdatedAt: Date;
|
69
|
+
|
70
|
+
@BelongsTo(() => User, 'CreatedById')
|
71
|
+
CreatedByUser: User;
|
72
|
+
|
73
|
+
@BelongsTo(() => User, 'UpdatedById')
|
74
|
+
UpdatedByUser: User;
|
75
|
+
|
76
|
+
@BelongsTo(() => SystemModel, 'SystemCode')
|
77
|
+
System: SystemModel;
|
78
|
+
|
79
|
+
@BelongsTo(() => GroupModel, 'GroupCode')
|
80
|
+
Group: GroupModel;
|
81
|
+
}
|