rez_core 3.1.148 → 3.1.150
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/module/auth/guards/role.guard.js +2 -2
- package/dist/module/auth/guards/role.guard.js.map +1 -1
- package/dist/module/auth/services/auth.service.js +1 -1
- package/dist/module/enterprise/entity/enterprise.entity.js +1 -1
- package/dist/module/enterprise/entity/enterprise.entity.js.map +1 -1
- package/dist/module/enterprise/entity/organization-app-mapping.entity.js +1 -1
- package/dist/module/enterprise/entity/organization-app-mapping.entity.js.map +1 -1
- package/dist/module/enterprise/entity/organization.entity.js +1 -1
- package/dist/module/enterprise/entity/organization.entity.js.map +1 -1
- package/dist/module/enterprise/repository/school.repository.js +7 -7
- package/dist/module/enterprise/repository/school.repository.js.map +1 -1
- package/dist/module/layout/entity/header-items.entity.js +1 -1
- package/dist/module/layout/entity/header-items.entity.js.map +1 -1
- package/dist/module/layout/entity/header-section.entity.js +1 -1
- package/dist/module/layout/entity/header-section.entity.js.map +1 -1
- package/dist/module/master/service/master.service.js +13 -13
- package/dist/module/master/service/master.service.js.map +1 -1
- package/dist/module/meta/entity/app-master.entity.js +1 -1
- package/dist/module/meta/entity/app-master.entity.js.map +1 -1
- package/dist/module/meta/service/resolver.service.js +9 -8
- package/dist/module/meta/service/resolver.service.js.map +1 -1
- package/dist/module/module/entity/menu.entity.js +1 -1
- package/dist/module/module/entity/menu.entity.js.map +1 -1
- package/dist/module/module/entity/module-access.entity.js +1 -1
- package/dist/module/module/entity/module-access.entity.js.map +1 -1
- package/dist/module/module/entity/module-action.entity.js +1 -1
- package/dist/module/module/entity/module-action.entity.js.map +1 -1
- package/dist/module/module/entity/module.entity.js +1 -1
- package/dist/module/module/entity/module.entity.js.map +1 -1
- package/dist/module/module/repository/menu.repository.js +7 -7
- package/dist/module/module/repository/menu.repository.js.map +1 -1
- package/dist/module/module/repository/module-access.repository.js +4 -2
- package/dist/module/module/repository/module-access.repository.js.map +1 -1
- package/dist/module/module/service/module-access.service.js +1 -1
- package/dist/module/module/service/module-access.service.js.map +1 -1
- package/dist/module/notification/entity/otp.entity.js +1 -1
- package/dist/module/notification/entity/otp.entity.js.map +1 -1
- package/dist/module/notification/service/otp.service.js +1 -1
- package/dist/module/notification/service/otp.service.js.map +1 -1
- package/dist/module/user/entity/role.entity.js +1 -1
- package/dist/module/user/entity/role.entity.js.map +1 -1
- package/dist/module/user/entity/user-role-mapping.entity.js +1 -1
- package/dist/module/user/entity/user-role-mapping.entity.js.map +1 -1
- package/dist/module/user/entity/user-session.entity.js +1 -1
- package/dist/module/user/entity/user-session.entity.js.map +1 -1
- package/dist/module/user/entity/user.entity.js +1 -1
- package/dist/module/user/entity/user.entity.js.map +1 -1
- package/dist/module/user/service/role.service.js +2 -2
- package/dist/module/user/service/user-session.service.js +10 -10
- package/dist/module/user/service/user-session.service.js.map +1 -1
- package/dist/module/workflow/repository/activity-log.repository.js +1 -1
- package/dist/module/workflow/repository/activity-log.repository.js.map +1 -1
- package/dist/module/workflow/service/task.service.js +1 -1
- package/dist/module/workflow/service/workflow-meta.service.js +5 -5
- package/dist/module/workflow/service/workflow-meta.service.js.map +1 -1
- package/dist/module/workflow-automation/entity/workflow-automation-action.entity.js +1 -1
- package/dist/module/workflow-automation/entity/workflow-automation-action.entity.js.map +1 -1
- package/dist/module/workflow-automation/entity/workflow-automation.entity.js +1 -1
- package/dist/module/workflow-automation/entity/workflow-automation.entity.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/module/auth/guards/role.guard.ts +2 -2
- package/src/module/auth/services/auth.service.ts +2 -2
- package/src/module/enterprise/entity/enterprise.entity.ts +1 -1
- package/src/module/enterprise/entity/organization-app-mapping.entity.ts +1 -1
- package/src/module/enterprise/entity/organization.entity.ts +1 -1
- package/src/module/enterprise/repository/school.repository.ts +7 -8
- package/src/module/layout/entity/header-items.entity.ts +1 -1
- package/src/module/layout/entity/header-section.entity.ts +1 -1
- package/src/module/master/service/master.service.ts +13 -13
- package/src/module/meta/entity/app-master.entity.ts +1 -1
- package/src/module/meta/service/resolver.service.ts +11 -8
- package/src/module/module/entity/menu.entity.ts +1 -1
- package/src/module/module/entity/module-access.entity.ts +1 -1
- package/src/module/module/entity/module-action.entity.ts +1 -1
- package/src/module/module/entity/module.entity.ts +1 -1
- package/src/module/module/repository/menu.repository.ts +7 -7
- package/src/module/module/repository/module-access.repository.ts +19 -15
- package/src/module/module/service/module-access.service.ts +1 -1
- package/src/module/notification/entity/otp.entity.ts +1 -1
- package/src/module/notification/service/otp.service.ts +1 -1
- package/src/module/user/entity/role.entity.ts +1 -1
- package/src/module/user/entity/user-role-mapping.entity.ts +1 -1
- package/src/module/user/entity/user-session.entity.ts +1 -1
- package/src/module/user/entity/user.entity.ts +1 -1
- package/src/module/user/service/role.service.ts +2 -2
- package/src/module/user/service/user-session.service.ts +10 -10
- package/src/module/workflow/repository/activity-log.repository.ts +1 -1
- package/src/module/workflow/service/task.service.ts +1 -1
- package/src/module/workflow/service/workflow-meta.service.ts +5 -5
- package/src/module/workflow-automation/entity/workflow-automation-action.entity.ts +1 -1
- package/src/module/workflow-automation/entity/workflow-automation.entity.ts +1 -1
- package/.vscode/extensions.json +0 -5
package/package.json
CHANGED
|
@@ -24,7 +24,7 @@ export class RolesGuard implements CanActivate {
|
|
|
24
24
|
const object = request.user;
|
|
25
25
|
|
|
26
26
|
const users: UserData = await this.entityManager.query(
|
|
27
|
-
`SELECT * FROM
|
|
27
|
+
`SELECT * FROM sso_user WHERE id = ${object.userId} LIMIT 1`,
|
|
28
28
|
);
|
|
29
29
|
|
|
30
30
|
const user = users[0];
|
|
@@ -43,7 +43,7 @@ export class RolesGuard implements CanActivate {
|
|
|
43
43
|
|
|
44
44
|
const roleAccess = await this.entityManager.query(
|
|
45
45
|
`SELECT *
|
|
46
|
-
FROM
|
|
46
|
+
FROM sso_module_access
|
|
47
47
|
WHERE role_id = ${user['role_id']}
|
|
48
48
|
AND module_code = '${requiredModule}'`,
|
|
49
49
|
);
|
|
@@ -37,9 +37,9 @@ export class AuthService {
|
|
|
37
37
|
) {
|
|
38
38
|
const { id: userId, organization_id } = loggedInUser;
|
|
39
39
|
|
|
40
|
-
// Update the
|
|
40
|
+
// Update the sso_user table
|
|
41
41
|
await this.dataSource.query(
|
|
42
|
-
`UPDATE
|
|
42
|
+
`UPDATE sso_user
|
|
43
43
|
SET fcm_token = ?, ip = ?, browser = ?, os = ?
|
|
44
44
|
WHERE id = ? AND organization_id = ?`,
|
|
45
45
|
[fcmtoken, ip, browser, os, userId, organization_id],
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';
|
|
2
2
|
|
|
3
|
-
@Entity({ name: '
|
|
3
|
+
@Entity({ name: 'sso_organization_app_mapping' })
|
|
4
4
|
export class OrganizationAppMapping {
|
|
5
5
|
@PrimaryGeneratedColumn({ name: 'id', type: 'int' })
|
|
6
6
|
id: number;
|
|
@@ -37,7 +37,6 @@ export class SchoolRepository {
|
|
|
37
37
|
.andWhere('urm.level_type = :levelType', { levelType: 'ORG' })
|
|
38
38
|
.getRawMany();
|
|
39
39
|
|
|
40
|
-
|
|
41
40
|
let currentORGLevel_id = hasOrgAccess[0]?.urm_level_id;
|
|
42
41
|
if (hasOrgAccess[0]?.urm_level_id == 1) {
|
|
43
42
|
currentORGLevel_id = org_id;
|
|
@@ -71,8 +70,8 @@ export class SchoolRepository {
|
|
|
71
70
|
'address.area AS school_location',
|
|
72
71
|
'school.status AS school_status',
|
|
73
72
|
])
|
|
74
|
-
.from('
|
|
75
|
-
.innerJoin('
|
|
73
|
+
.from('sso_organization', 'org')
|
|
74
|
+
.innerJoin('sso_organization', 'brn', "brn.type = 'BRN'")
|
|
76
75
|
.innerJoin(
|
|
77
76
|
'eth_brand_profile',
|
|
78
77
|
'brand_profile',
|
|
@@ -174,7 +173,7 @@ export class SchoolRepository {
|
|
|
174
173
|
|
|
175
174
|
orgDetails
|
|
176
175
|
.select(['*'])
|
|
177
|
-
.from('
|
|
176
|
+
.from('sso_organization', 'org')
|
|
178
177
|
.where('org.id = :orgId', { orgId: currentORGLevel_id });
|
|
179
178
|
|
|
180
179
|
const orgResult = await orgDetails.getRawOne();
|
|
@@ -202,8 +201,8 @@ export class SchoolRepository {
|
|
|
202
201
|
'address.area AS school_location',
|
|
203
202
|
'school.status AS school_status',
|
|
204
203
|
])
|
|
205
|
-
.from('
|
|
206
|
-
.innerJoin('
|
|
204
|
+
.from('sso_user_role_mapping', 'urm')
|
|
205
|
+
.innerJoin('sso_organization', 'brand', 'brand.id = urm.level_id')
|
|
207
206
|
.innerJoin('eth_school_profile', 'school', 'school.brand_id = brand.id')
|
|
208
207
|
.innerJoin('eth_address', 'address', 'address.parent_id = school.id')
|
|
209
208
|
.where('urm.user_id = :userId', { userId })
|
|
@@ -223,9 +222,9 @@ export class SchoolRepository {
|
|
|
223
222
|
'address.area AS school_location',
|
|
224
223
|
'school.status AS school_status',
|
|
225
224
|
])
|
|
226
|
-
.from('
|
|
225
|
+
.from('sso_user_role_mapping', 'urm')
|
|
227
226
|
.innerJoin('eth_school_profile', 'school', 'school.id = urm.level_id')
|
|
228
|
-
.innerJoin('
|
|
227
|
+
.innerJoin('sso_organization', 'brand', 'brand.id = school.brand_id')
|
|
229
228
|
.innerJoin('eth_address', 'address', 'address.parent_id = school.id')
|
|
230
229
|
.where('urm.user_id = :userId', { userId })
|
|
231
230
|
.andWhere('urm.appcode = :appCode', { appCode })
|
|
@@ -65,43 +65,43 @@ export class MasterService {
|
|
|
65
65
|
unique_fields: ['mapped_entity_type', 'organization_id'],
|
|
66
66
|
},
|
|
67
67
|
{
|
|
68
|
-
table: '
|
|
68
|
+
table: 'sso_user',
|
|
69
69
|
unique_fields: ['organization_id'],
|
|
70
70
|
},
|
|
71
71
|
{
|
|
72
|
-
table: '
|
|
72
|
+
table: 'sso_header_items',
|
|
73
73
|
unique_fields: ['code', 'section_id', 'organization_id'],
|
|
74
74
|
},
|
|
75
75
|
{
|
|
76
|
-
table: '
|
|
76
|
+
table: 'sso_module_access',
|
|
77
77
|
unique_fields: ['module_code', 'action_type', 'role_code'],
|
|
78
78
|
},
|
|
79
79
|
{
|
|
80
|
-
table: '
|
|
80
|
+
table: 'sso_module_action',
|
|
81
81
|
unique_fields: ['module_code', 'action_type', 'organization_id'],
|
|
82
82
|
},
|
|
83
83
|
{
|
|
84
|
-
table: '
|
|
84
|
+
table: 'sso_menu',
|
|
85
85
|
unique_fields: ['module_code', 'organization_id'],
|
|
86
86
|
},
|
|
87
87
|
{
|
|
88
|
-
table: '
|
|
88
|
+
table: 'sso_module',
|
|
89
89
|
unique_fields: ['module_code', 'organization_id'],
|
|
90
90
|
},
|
|
91
91
|
{
|
|
92
|
-
table: '
|
|
92
|
+
table: 'sso_role',
|
|
93
93
|
unique_fields: ['code', 'organization_id'],
|
|
94
94
|
},
|
|
95
95
|
{
|
|
96
|
-
table: '
|
|
96
|
+
table: 'sso_header_sections',
|
|
97
97
|
unique_fields: ['section_name', 'organization_id'],
|
|
98
98
|
},
|
|
99
99
|
{
|
|
100
|
-
table: '
|
|
100
|
+
table: 'sso_user_role_mapping',
|
|
101
101
|
unique_fields: ['user_id', 'role_id', 'organization_id'],
|
|
102
102
|
},
|
|
103
103
|
{
|
|
104
|
-
table: '
|
|
104
|
+
table: 'sso_organization',
|
|
105
105
|
unique_fields: ['code'],
|
|
106
106
|
},
|
|
107
107
|
{
|
|
@@ -111,15 +111,15 @@ export class MasterService {
|
|
|
111
111
|
];
|
|
112
112
|
private readonly dataSequence = [
|
|
113
113
|
{
|
|
114
|
-
table: '
|
|
114
|
+
table: 'sso_user',
|
|
115
115
|
unique_fields: ['code'],
|
|
116
116
|
},
|
|
117
117
|
{
|
|
118
|
-
table: '
|
|
118
|
+
table: 'sso_role',
|
|
119
119
|
unique_fields: ['code'],
|
|
120
120
|
},
|
|
121
121
|
{
|
|
122
|
-
table: '
|
|
122
|
+
table: 'sso_user_role_mapping',
|
|
123
123
|
unique_fields: ['user_id', 'role_id'],
|
|
124
124
|
},
|
|
125
125
|
{
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';
|
|
2
2
|
import { BaseEntity } from './base-entity.entity';
|
|
3
3
|
|
|
4
|
-
@Entity({ name: '
|
|
4
|
+
@Entity({ name: 'sso_app_master' })
|
|
5
5
|
export class AppMaster extends BaseEntity {
|
|
6
6
|
constructor() {
|
|
7
7
|
super();
|
|
@@ -44,7 +44,7 @@ export class ResolverService {
|
|
|
44
44
|
const resolvedValues: string[] = [];
|
|
45
45
|
|
|
46
46
|
for (const code of codeValue) {
|
|
47
|
-
if (tableName == '
|
|
47
|
+
if (tableName == 'sso_organization') {
|
|
48
48
|
const [item] = await this.dataSource.query(
|
|
49
49
|
`SELECT * FROM ${tableName} WHERE code = ?`,
|
|
50
50
|
[code],
|
|
@@ -61,7 +61,10 @@ export class ResolverService {
|
|
|
61
61
|
|
|
62
62
|
resolvedEntityData[field] = resolvedValues;
|
|
63
63
|
} else {
|
|
64
|
-
if (
|
|
64
|
+
if (
|
|
65
|
+
tableName == 'sso_organization' ||
|
|
66
|
+
tableName == 'sso_app_master'
|
|
67
|
+
) {
|
|
65
68
|
const [item] = await this.dataSource.query(
|
|
66
69
|
`SELECT * FROM ${tableName} WHERE id = ?`,
|
|
67
70
|
[codeValue],
|
|
@@ -154,12 +157,12 @@ export class ResolverService {
|
|
|
154
157
|
const resolvedValues: string[] = [];
|
|
155
158
|
for (const code of rawValue) {
|
|
156
159
|
const query =
|
|
157
|
-
tableName === '
|
|
160
|
+
tableName === 'sso_organization'
|
|
158
161
|
? `SELECT * FROM ${tableName} WHERE code = ?`
|
|
159
162
|
: `SELECT * FROM ${tableName} WHERE id = ? AND organization_id = ?`;
|
|
160
163
|
|
|
161
164
|
const params =
|
|
162
|
-
tableName === '
|
|
165
|
+
tableName === 'sso_organization'
|
|
163
166
|
? [code]
|
|
164
167
|
: [code, loggedInUser.organization_id];
|
|
165
168
|
|
|
@@ -169,12 +172,12 @@ export class ResolverService {
|
|
|
169
172
|
return resolvedValues;
|
|
170
173
|
} else {
|
|
171
174
|
const query =
|
|
172
|
-
tableName === '
|
|
175
|
+
tableName === 'sso_organization'
|
|
173
176
|
? `SELECT * FROM ${tableName} WHERE id = ?`
|
|
174
177
|
: `SELECT * FROM ${tableName} WHERE id = ? AND organization_id = ?`;
|
|
175
178
|
|
|
176
179
|
const params =
|
|
177
|
-
tableName === '
|
|
180
|
+
tableName === 'sso_organization'
|
|
178
181
|
? [rawValue]
|
|
179
182
|
: [rawValue, loggedInUser.organization_id];
|
|
180
183
|
|
|
@@ -243,12 +246,12 @@ export class ResolverService {
|
|
|
243
246
|
const tableName = entityDef.db_table_name;
|
|
244
247
|
|
|
245
248
|
const query =
|
|
246
|
-
tableName === '
|
|
249
|
+
tableName === 'sso_organization'
|
|
247
250
|
? `SELECT id FROM ${tableName} WHERE ${attr.data_source_attribute} = ?`
|
|
248
251
|
: `SELECT id FROM ${tableName} WHERE ${attr.data_source_attribute} = ? AND organization_id = ?`;
|
|
249
252
|
|
|
250
253
|
const params =
|
|
251
|
-
tableName === '
|
|
254
|
+
tableName === 'sso_organization'
|
|
252
255
|
? [displayValue]
|
|
253
256
|
: [displayValue, loggedInUser.organization_id];
|
|
254
257
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Column, Entity, PrimaryGeneratedColumn, Unique } from 'typeorm';
|
|
2
2
|
|
|
3
|
-
@Entity({ name: '
|
|
3
|
+
@Entity({ name: 'sso_module_action' }) // <- new table name
|
|
4
4
|
@Unique(['module_code', 'action_type']) // enforce uniqueness per module + action
|
|
5
5
|
export class ModuleAction {
|
|
6
6
|
@PrimaryGeneratedColumn()
|
|
@@ -20,7 +20,7 @@ export class MenuRepository extends Repository<MenuData> {
|
|
|
20
20
|
const roles = await this.dataSource
|
|
21
21
|
.getRepository(UserRoleMapping)
|
|
22
22
|
.createQueryBuilder('urm')
|
|
23
|
-
.innerJoin('
|
|
23
|
+
.innerJoin('sso_role', 'role', 'role.id = urm.role_id')
|
|
24
24
|
.select('urm.role_id')
|
|
25
25
|
.where('urm.user_id = :userId', { userId })
|
|
26
26
|
.andWhere('role.appcode = :appcode', { appcode })
|
|
@@ -66,7 +66,7 @@ export class MenuRepository extends Repository<MenuData> {
|
|
|
66
66
|
return await this.menuData
|
|
67
67
|
.createQueryBuilder('menu')
|
|
68
68
|
.leftJoin(
|
|
69
|
-
'
|
|
69
|
+
'sso_module',
|
|
70
70
|
'module',
|
|
71
71
|
`
|
|
72
72
|
menu.module_code = module.module_code
|
|
@@ -101,7 +101,7 @@ export class MenuRepository extends Repository<MenuData> {
|
|
|
101
101
|
// Check if user has any role mappings for the given appcode
|
|
102
102
|
const getUserDetails = await this.dataSource.query(
|
|
103
103
|
`
|
|
104
|
-
SELECT * from
|
|
104
|
+
SELECT * from sso_user where id = ?
|
|
105
105
|
`,
|
|
106
106
|
[userId],
|
|
107
107
|
);
|
|
@@ -110,7 +110,7 @@ export class MenuRepository extends Repository<MenuData> {
|
|
|
110
110
|
|
|
111
111
|
const getUserUrm = await this.dataSource.query(
|
|
112
112
|
`
|
|
113
|
-
SELECT * from
|
|
113
|
+
SELECT * from sso_user_role_mapping where user_id = ? and appcode = ?
|
|
114
114
|
`,
|
|
115
115
|
[userId, appcode],
|
|
116
116
|
);
|
|
@@ -126,7 +126,7 @@ export class MenuRepository extends Repository<MenuData> {
|
|
|
126
126
|
// 1. Try exact level match
|
|
127
127
|
let roles = await repo
|
|
128
128
|
.createQueryBuilder('urm')
|
|
129
|
-
.innerJoin('
|
|
129
|
+
.innerJoin('sso_role', 'role', 'role.id = urm.role_id')
|
|
130
130
|
.select('urm.role_id')
|
|
131
131
|
.where('urm.user_id = :userId', { userId })
|
|
132
132
|
.andWhere('urm.level_type = :levelType', { levelType })
|
|
@@ -153,7 +153,7 @@ export class MenuRepository extends Repository<MenuData> {
|
|
|
153
153
|
if (brandId) {
|
|
154
154
|
roles = await repo
|
|
155
155
|
.createQueryBuilder('urm')
|
|
156
|
-
.innerJoin('
|
|
156
|
+
.innerJoin('sso_role', 'role', 'role.id = urm.role_id')
|
|
157
157
|
.select('urm.role_id')
|
|
158
158
|
.where('urm.user_id = :userId', { userId })
|
|
159
159
|
.andWhere('urm.level_type = :levelType', { levelType: 'BRN' })
|
|
@@ -167,7 +167,7 @@ export class MenuRepository extends Repository<MenuData> {
|
|
|
167
167
|
if (orgId) {
|
|
168
168
|
roles = await repo
|
|
169
169
|
.createQueryBuilder('urm')
|
|
170
|
-
.innerJoin('
|
|
170
|
+
.innerJoin('sso_role', 'role', 'role.id = urm.role_id')
|
|
171
171
|
.select('urm.role_id')
|
|
172
172
|
.where('urm.user_id = :userId', { userId })
|
|
173
173
|
.andWhere('urm.level_type = :levelType', { levelType: 'ORG' })
|
|
@@ -36,7 +36,7 @@ export class ModuleAccessRepository {
|
|
|
36
36
|
const query = this.dataSource
|
|
37
37
|
.createQueryBuilder()
|
|
38
38
|
.select('*')
|
|
39
|
-
.from('
|
|
39
|
+
.from('sso_role', 'role')
|
|
40
40
|
.where('role.appcode = :appcode', { appcode })
|
|
41
41
|
.andWhere('(role.is_factory IS NULL OR role.is_factory != 1)');
|
|
42
42
|
|
|
@@ -145,19 +145,23 @@ export class ModuleAccessRepository {
|
|
|
145
145
|
const wbsCodes = mainModules.map((mod) => mod.wbs_code);
|
|
146
146
|
|
|
147
147
|
let allModules = await this.moduleRepo
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
148
|
+
.createQueryBuilder('module')
|
|
149
|
+
.where(
|
|
150
|
+
wbsCodes
|
|
151
|
+
.map((code) => `module.wbs_code LIKE :code${code}`)
|
|
152
|
+
.join(' OR '),
|
|
153
|
+
Object.fromEntries(wbsCodes.map((code) => [`code${code}`, `${code}%`])),
|
|
154
|
+
)
|
|
155
|
+
.andWhere('module.appcode = :appcode', { appcode })
|
|
156
|
+
.andWhere('module.module_code != :excludedCode', {
|
|
157
|
+
excludedCode: 'all_organization_adm_org',
|
|
158
|
+
})
|
|
159
|
+
.getMany();
|
|
160
|
+
|
|
161
|
+
allModules = allModules.filter(
|
|
162
|
+
(mod) => mod.module_code != 'all_organization_adm_org',
|
|
163
|
+
);
|
|
164
|
+
|
|
161
165
|
const moduleCodes = allModules.map((m) => m.module_code);
|
|
162
166
|
|
|
163
167
|
const allActions = await this.moduleActionRepo.find({
|
|
@@ -289,7 +293,7 @@ export class ModuleAccessRepository {
|
|
|
289
293
|
};
|
|
290
294
|
}
|
|
291
295
|
async getModuleAccessByRoles(roleIds: number[], appcode: string) {
|
|
292
|
-
// Step 1: Get role codes from
|
|
296
|
+
// Step 1: Get role codes from sso_role
|
|
293
297
|
const roles = await this.roleRepo.find({
|
|
294
298
|
where: {
|
|
295
299
|
id: In(roleIds),
|
|
@@ -44,7 +44,7 @@ export class ModuleAccessService {
|
|
|
44
44
|
const query = this.dataSource
|
|
45
45
|
.createQueryBuilder()
|
|
46
46
|
.select('*')
|
|
47
|
-
.from('
|
|
47
|
+
.from('sso_role', 'role')
|
|
48
48
|
.where('role.appcode = :appcode', { appcode });
|
|
49
49
|
|
|
50
50
|
// Only add this condition if `include` is false (exclude factory roles)
|
|
@@ -40,7 +40,7 @@ export class OtpService {
|
|
|
40
40
|
otp.expiration_date = new Date(Date.now() + expiresIn * 60 * 1000);
|
|
41
41
|
|
|
42
42
|
const userData = await this.dataSource
|
|
43
|
-
.getRepository('
|
|
43
|
+
.getRepository('sso_user')
|
|
44
44
|
.findOne({ where: { email_id: identifier } });
|
|
45
45
|
|
|
46
46
|
const data = {
|
|
@@ -3,7 +3,7 @@ import { ENTITYTYPE_ROLE } from '../../../constant/global.constant';
|
|
|
3
3
|
import { Column, Entity } from 'typeorm';
|
|
4
4
|
import { Exclude } from 'class-transformer';
|
|
5
5
|
|
|
6
|
-
@Entity({ name: '
|
|
6
|
+
@Entity({ name: 'sso_role' })
|
|
7
7
|
export class Role extends BaseEntity {
|
|
8
8
|
constructor() {
|
|
9
9
|
super();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ENTITYTYPE_USRROLMAP } from 'src/constant/global.constant';
|
|
2
2
|
import { Column, Entity, PrimaryGeneratedColumn } from 'typeorm';
|
|
3
3
|
|
|
4
|
-
@Entity({ name: '
|
|
4
|
+
@Entity({ name: 'sso_user_role_mapping' })
|
|
5
5
|
export class UserRoleMapping {
|
|
6
6
|
constructor(user_id: number, role_id: number) {
|
|
7
7
|
this.user_id = user_id;
|
|
@@ -2,7 +2,7 @@ import { Column, Entity } from 'typeorm';
|
|
|
2
2
|
import { ENTITYTYPE_USER } from '../../../constant/global.constant';
|
|
3
3
|
import { BaseEntity } from '../../meta/entity/base-entity.entity';
|
|
4
4
|
|
|
5
|
-
@Entity({ name: '
|
|
5
|
+
@Entity({ name: 'sso_user' })
|
|
6
6
|
export class UserData extends BaseEntity {
|
|
7
7
|
constructor() {
|
|
8
8
|
super();
|
|
@@ -108,8 +108,8 @@ export class RoleService extends EntityServiceImpl {
|
|
|
108
108
|
}
|
|
109
109
|
|
|
110
110
|
const associatedUsers = await this.entityManager.query(`SELECT map.*
|
|
111
|
-
FROM
|
|
112
|
-
JOIN
|
|
111
|
+
FROM sso_user_role_mapping map
|
|
112
|
+
JOIN sso_user usr ON map.user_id = usr.id
|
|
113
113
|
WHERE usr.status = ${resolveStatus.id}
|
|
114
114
|
and map.role_id = ${existingRole?.id}`);
|
|
115
115
|
|
|
@@ -92,7 +92,7 @@ export class UserSessionService {
|
|
|
92
92
|
// Check if user has any role mappings for the given appcode
|
|
93
93
|
getUserDetails = await this.dataSource.query(
|
|
94
94
|
`
|
|
95
|
-
SELECT * from
|
|
95
|
+
SELECT * from sso_user where id = ?
|
|
96
96
|
`,
|
|
97
97
|
[currentUser.id],
|
|
98
98
|
);
|
|
@@ -103,7 +103,7 @@ export class UserSessionService {
|
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
await this.dataSource.query(
|
|
106
|
-
`UPDATE
|
|
106
|
+
`UPDATE sso_user SET last_app_access = ? , last_level_type = ?, last_level_id = ? WHERE id = ?`,
|
|
107
107
|
[data.appcode, data.level_type, data.level_id, currentUser.id],
|
|
108
108
|
);
|
|
109
109
|
|
|
@@ -124,11 +124,11 @@ export class UserSessionService {
|
|
|
124
124
|
): Promise<boolean> {
|
|
125
125
|
const count = await this.dataSource
|
|
126
126
|
.getRepository(UserRoleMapping)
|
|
127
|
-
.createQueryBuilder('
|
|
128
|
-
.where('
|
|
129
|
-
.andWhere('
|
|
130
|
-
.andWhere('
|
|
131
|
-
.andWhere('
|
|
127
|
+
.createQueryBuilder('sso_user_role_mapping')
|
|
128
|
+
.where('sso_user_role_mapping.user_id = :userId', { userId })
|
|
129
|
+
.andWhere('sso_user_role_mapping.appcode = :appcode', { appcode })
|
|
130
|
+
.andWhere('sso_user_role_mapping.level_type = :levelType', { levelType })
|
|
131
|
+
.andWhere('sso_user_role_mapping.level_id = :levelId', { levelId })
|
|
132
132
|
.getCount();
|
|
133
133
|
|
|
134
134
|
return count > 0;
|
|
@@ -137,9 +137,9 @@ export class UserSessionService {
|
|
|
137
137
|
async getUserRoleMappingForApp(userId: number, appcode: string) {
|
|
138
138
|
const mapping = await this.dataSource
|
|
139
139
|
.getRepository(UserRoleMapping)
|
|
140
|
-
.createQueryBuilder('
|
|
141
|
-
.where('
|
|
142
|
-
.andWhere('
|
|
140
|
+
.createQueryBuilder('sso_user_role_mapping')
|
|
141
|
+
.where('sso_user_role_mapping.user_id = :userId', { userId })
|
|
142
|
+
.andWhere('sso_user_role_mapping.appcode = :appcode', { appcode })
|
|
143
143
|
.getOne();
|
|
144
144
|
|
|
145
145
|
// If not found or is already ORG/SCH, return directly
|
|
@@ -37,7 +37,7 @@ export class ActivityLogRepository {
|
|
|
37
37
|
|
|
38
38
|
const query = this.activityLogRepository
|
|
39
39
|
.createQueryBuilder('log')
|
|
40
|
-
.leftJoin('
|
|
40
|
+
.leftJoin('sso_user', 'user', 'log.created_by = user.id')
|
|
41
41
|
.leftJoin('eth_user_profile', 'profile', 'profile.parent_id = user.id')
|
|
42
42
|
.addSelect('user.name', 'user_name')
|
|
43
43
|
.addSelect('profile.profile_image', 'profile_image') // media ID
|
|
@@ -286,7 +286,7 @@ export class TaskService extends EntityServiceImpl {
|
|
|
286
286
|
LEFT JOIN cr_wf_stage s ON t.stage_id = s.id
|
|
287
287
|
LEFT JOIN cr_wf_stage_group sg ON s.stage_group_id = sg.id
|
|
288
288
|
LEFT JOIN cr_wf_action a ON t.action_id = a.id
|
|
289
|
-
LEFT JOIN
|
|
289
|
+
LEFT JOIN sso_user u ON t.created_by = u.id
|
|
290
290
|
LEFT JOIN eth_user_profile u2 ON t.task_owner = u2.parent_id
|
|
291
291
|
WHERE ${whereClauses.join(' AND ')}
|
|
292
292
|
ORDER BY t.created_date DESC
|
|
@@ -441,7 +441,7 @@ export class WorkflowMetaService extends EntityServiceImpl {
|
|
|
441
441
|
}
|
|
442
442
|
|
|
443
443
|
const leadOwnerName = await this.dataSource.query(
|
|
444
|
-
`SELECT name FROM
|
|
444
|
+
`SELECT name FROM sso_user WHERE id = ?`,
|
|
445
445
|
[entityData?.lead_owner],
|
|
446
446
|
);
|
|
447
447
|
|
|
@@ -482,10 +482,10 @@ export class WorkflowMetaService extends EntityServiceImpl {
|
|
|
482
482
|
const owners: Array<{ id: number }> = await this.dataSource.query(
|
|
483
483
|
`
|
|
484
484
|
SELECT DISTINCT u.id
|
|
485
|
-
FROM
|
|
486
|
-
JOIN
|
|
487
|
-
JOIN
|
|
488
|
-
JOIN
|
|
485
|
+
FROM sso_user u
|
|
486
|
+
JOIN sso_user_role_mapping urm ON u.id = urm.user_id
|
|
487
|
+
JOIN sso_role r ON urm.role_id = r.id
|
|
488
|
+
JOIN sso_module_access ma ON ma.role_code = r.code
|
|
489
489
|
WHERE urm.organization_id = ?
|
|
490
490
|
AND urm.level_id = ?
|
|
491
491
|
AND urm.level_type = ?
|
|
@@ -2,7 +2,7 @@ import { WORKFLOW_AUTOMATION_ACTION } from 'src/constant/global.constant';
|
|
|
2
2
|
import { BaseEntity } from 'src/module/meta/entity/base-entity.entity';
|
|
3
3
|
import { Column, Entity } from 'typeorm';
|
|
4
4
|
|
|
5
|
-
@Entity({ name: '
|
|
5
|
+
@Entity({ name: 'cr_wf_automation_action' })
|
|
6
6
|
export class WorkflowAutomationActionEntity extends BaseEntity {
|
|
7
7
|
constructor() {
|
|
8
8
|
super();
|
|
@@ -2,7 +2,7 @@ import { WORKFLOW_AUTOMATION } from 'src/constant/global.constant';
|
|
|
2
2
|
import { BaseEntity } from 'src/module/meta/entity/base-entity.entity';
|
|
3
3
|
import { Column, Entity } from 'typeorm';
|
|
4
4
|
|
|
5
|
-
@Entity({ name: '
|
|
5
|
+
@Entity({ name: 'cr_wf_automation' })
|
|
6
6
|
export class WorkflowAutomation extends BaseEntity {
|
|
7
7
|
constructor() {
|
|
8
8
|
super();
|