@tomei/sso 0.50.6 → 0.50.8
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/src/components/login-user/user.d.ts +1 -1
- package/dist/src/components/login-user/user.js.map +1 -1
- package/dist/src/components/user-group/user-group.d.ts +1 -0
- package/dist/src/components/user-group/user-group.js +30 -0
- package/dist/src/components/user-group/user-group.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/components/login-user/user.ts +1 -1
- package/src/components/user-group/user-group.ts +54 -0
package/package.json
CHANGED
@@ -8,6 +8,7 @@ import { ActionEnum, Activity } from '@tomei/activity-history';
|
|
8
8
|
import GroupSystemAccessModel from '../../models/group-system-access.entity';
|
9
9
|
import GroupModel from '../../models/group.entity';
|
10
10
|
import SystemModel from '../../models/system.entity';
|
11
|
+
import UserModel from '../../models/user.entity';
|
11
12
|
import { Transaction } from 'sequelize';
|
12
13
|
|
13
14
|
export class UserGroup extends ObjectBase {
|
@@ -301,6 +302,59 @@ export class UserGroup extends ObjectBase {
|
|
301
302
|
}
|
302
303
|
}
|
303
304
|
|
305
|
+
public static async getUser(
|
306
|
+
dbTransaction: any,
|
307
|
+
loginUser: LoginUser,
|
308
|
+
GroupCode: string,
|
309
|
+
) {
|
310
|
+
try {
|
311
|
+
// Part 1: Privilege Checking
|
312
|
+
// Call loginUser.checkPrivileges() by passing:
|
313
|
+
// SystemCode: "<get_from_app_config>"
|
314
|
+
// PrivilegeCode: "USER_GROUP_VIEW"
|
315
|
+
const systemCode =
|
316
|
+
ApplicationConfig.getComponentConfigValue('system-code');
|
317
|
+
const isPrivileged = await loginUser.checkPrivileges(
|
318
|
+
systemCode,
|
319
|
+
'USER_GROUP_VIEW',
|
320
|
+
);
|
321
|
+
|
322
|
+
// If user does not have privilege to view user group, throw a ClassError
|
323
|
+
if (!isPrivileged) {
|
324
|
+
throw new ClassError(
|
325
|
+
'UserGroup',
|
326
|
+
'UserGroupErrMsg0X',
|
327
|
+
'User does not have privilege to view user group.',
|
328
|
+
);
|
329
|
+
}
|
330
|
+
|
331
|
+
// Part 2: Retrieve Record
|
332
|
+
// Call UserGroup._Repo findAll method by passing:
|
333
|
+
// where:
|
334
|
+
// GroupCode: Params.GroupCode
|
335
|
+
// dbTransaction
|
336
|
+
const userGroup = await UserGroup._Repository.findAll({
|
337
|
+
where: {
|
338
|
+
GroupCode,
|
339
|
+
},
|
340
|
+
include: [
|
341
|
+
{
|
342
|
+
model: UserModel,
|
343
|
+
as: 'User',
|
344
|
+
attributes: ['UserId', 'FullName', 'Email'],
|
345
|
+
},
|
346
|
+
],
|
347
|
+
transaction: dbTransaction,
|
348
|
+
});
|
349
|
+
// If record exists, instantiate UserGroup by calling the private constructor and passing the attributes. Then, returns the instance
|
350
|
+
return userGroup;
|
351
|
+
// If record not exists, return null.
|
352
|
+
return null;
|
353
|
+
} catch (error) {
|
354
|
+
throw error;
|
355
|
+
}
|
356
|
+
}
|
357
|
+
|
304
358
|
static async findAllInheritedSystemAccesses(
|
305
359
|
UserId: number,
|
306
360
|
loginUser: User,
|