rez_core 5.0.131 → 5.0.134
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/config/bull.config.js +2 -2
- package/dist/config/bull.config.js.map +1 -1
- package/dist/module/meta/entity/app-master.entity.d.ts +1 -0
- package/dist/module/meta/entity/app-master.entity.js +4 -0
- package/dist/module/meta/entity/app-master.entity.js.map +1 -1
- package/dist/module/meta/service/entity-dynamic.service.js +8 -7
- package/dist/module/meta/service/entity-dynamic.service.js.map +1 -1
- package/dist/module/user/service/user-session.service.d.ts +1 -11
- package/dist/module/user/service/user-session.service.js +24 -18
- package/dist/module/user/service/user-session.service.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/config/bull.config.ts +2 -2
- package/src/module/meta/entity/app-master.entity.ts +3 -0
- package/src/module/meta/service/entity-dynamic.service.ts +10 -10
- package/src/module/user/service/user-session.service.ts +77 -51
- package/.idea/inspectionProfiles/Project_Default.xml +0 -6
- package/.idea/prettier.xml +0 -6
package/package.json
CHANGED
|
@@ -13,9 +13,9 @@ export class BullConfigService implements SharedBullConfigurationFactory {
|
|
|
13
13
|
createSharedConfiguration(): BullModuleOptions {
|
|
14
14
|
return {
|
|
15
15
|
redis: {
|
|
16
|
-
host: this.configService.get<string>('REDIS_HOST', '
|
|
16
|
+
host: this.configService.get<string>('REDIS_HOST', '43.205.35.45'),
|
|
17
17
|
port: this.configService.get<number>('REDIS_PORT', 6379),
|
|
18
|
-
password: this.configService.get<string>('REDIS_PASSWORD'),
|
|
18
|
+
password: this.configService.get<string>('REDIS_PASSWORD','Rezolut123'),
|
|
19
19
|
db: this.configService.get<number>('REDIS_DB', 0),
|
|
20
20
|
// Enable offline queue to handle Redis disconnections
|
|
21
21
|
enableOfflineQueue: true,
|
|
@@ -71,18 +71,18 @@ export class EntityDynamicService {
|
|
|
71
71
|
// -------------------------------------------------------
|
|
72
72
|
// AUTO-CODE GENERATION (POSTGRES SAFE)
|
|
73
73
|
// -------------------------------------------------------
|
|
74
|
-
|
|
74
|
+
const entityMaster = await this.entityMasterRepo.getEntityByMappedEntityType(entityType, loggedInUser.organization_id)
|
|
75
|
+
|
|
76
|
+
if (!entityData.code && entityData.entity_type && entityMaster) {
|
|
75
77
|
// Extract integer suffix
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
[entityData.entity_type],
|
|
83
|
-
);
|
|
78
|
+
const repo = this.reflectionHelper.getRepoService(entityMaster.entity_data_class);
|
|
79
|
+
|
|
80
|
+
const result = await repo
|
|
81
|
+
.createQueryBuilder()
|
|
82
|
+
.select('MAX(id)', 'seq_no')
|
|
83
|
+
.getRawOne();
|
|
84
84
|
|
|
85
|
-
let maxSeq = Number(result?.
|
|
85
|
+
let maxSeq = Number(result?.max_seq_no) || 0;
|
|
86
86
|
maxSeq++;
|
|
87
87
|
entityData.code = `${entityData.entity_type}${maxSeq}`;
|
|
88
88
|
}
|
|
@@ -19,10 +19,10 @@ export class UserSessionService {
|
|
|
19
19
|
private readonly clockIDGenService: ClockIDGenService,
|
|
20
20
|
private configService: ConfigService,
|
|
21
21
|
@InjectRepository(UserData)
|
|
22
|
-
private readonly
|
|
22
|
+
private readonly userDataRepository: Repository<UserData>,
|
|
23
23
|
@InjectRepository(UserRoleMapping)
|
|
24
|
-
private readonly
|
|
25
|
-
private readonly reflectionHelper: ReflectionHelper
|
|
24
|
+
private readonly userRoleMappingRepository: Repository<UserRoleMapping>,
|
|
25
|
+
private readonly reflectionHelper: ReflectionHelper,
|
|
26
26
|
) {}
|
|
27
27
|
async createSession(user, appcode?: string, accessInfo?: any) {
|
|
28
28
|
const sessionToken = this.clockIDGenService.idGenerator('SES');
|
|
@@ -98,8 +98,8 @@ export class UserSessionService {
|
|
|
98
98
|
getUserDetails = await this.userDataRepository.findOne({
|
|
99
99
|
where: {
|
|
100
100
|
id: currentUser.id,
|
|
101
|
-
}
|
|
102
|
-
})
|
|
101
|
+
},
|
|
102
|
+
});
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
if (getUserDetails?.organization_id == 1 && payload.level_type == 'ORG') {
|
|
@@ -122,56 +122,82 @@ export class UserSessionService {
|
|
|
122
122
|
}
|
|
123
123
|
|
|
124
124
|
async checkIfUserHasMapping(
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
125
|
+
userId: number,
|
|
126
|
+
appcode: string,
|
|
127
|
+
levelType: string,
|
|
128
|
+
levelId: string,
|
|
129
|
+
): Promise<boolean> {
|
|
130
|
+
// Get repositories dynamically via reflectionHelper
|
|
131
|
+
const userRoleMappingRepo =
|
|
132
|
+
this.reflectionHelper.getRepoService('UserRoleMapping');
|
|
133
|
+
const appMasterRepo =
|
|
134
|
+
this.reflectionHelper.getRepoService('AppMaster');
|
|
135
|
+
|
|
136
|
+
// Use QueryBuilder with proper aliases
|
|
137
|
+
const count = await userRoleMappingRepo
|
|
138
|
+
.createQueryBuilder('urm')
|
|
139
|
+
.innerJoin(
|
|
140
|
+
appMasterRepo.metadata.tableName,
|
|
141
|
+
'app',
|
|
142
|
+
'app.appcode = urm.appcode',
|
|
143
|
+
)
|
|
144
|
+
.where('urm.user_id = :userId', { userId })
|
|
145
|
+
.andWhere('urm.appcode = :appcode', { appcode })
|
|
146
|
+
.andWhere('urm.level_type = :levelType', { levelType })
|
|
147
|
+
.andWhere('urm.level_id = :levelId', { levelId })
|
|
148
|
+
.andWhere('app.show_in_ui = true')
|
|
149
|
+
.getCount();
|
|
150
|
+
|
|
151
|
+
return count > 0;
|
|
152
|
+
}
|
|
153
|
+
|
|
141
154
|
|
|
142
155
|
async getUserRoleMappingForApp(userId: number, appcode: string) {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
156
|
+
// Get repos dynamically
|
|
157
|
+
const userRoleMappingRepo =
|
|
158
|
+
this.reflectionHelper.getRepoService('UserRoleMapping');
|
|
159
|
+
|
|
160
|
+
const appMasterRepo =
|
|
161
|
+
this.reflectionHelper.getRepoService('AppMaster');
|
|
162
|
+
|
|
163
|
+
// Build dynamic join using metadata
|
|
164
|
+
const mapping = await userRoleMappingRepo
|
|
165
|
+
.createQueryBuilder('urm')
|
|
166
|
+
.innerJoin(
|
|
167
|
+
appMasterRepo.metadata.tableName,
|
|
168
|
+
'app',
|
|
169
|
+
'app.appcode = urm.appcode',
|
|
170
|
+
)
|
|
171
|
+
.where('urm.user_id = :userId', { userId })
|
|
172
|
+
.andWhere('urm.appcode = :appcode', { appcode })
|
|
173
|
+
.andWhere('app.show_in_ui = true')
|
|
174
|
+
.getOne();
|
|
175
|
+
|
|
176
|
+
// If not found or level_type is not BRN → return
|
|
177
|
+
if (!mapping || mapping.level_type !== 'BRN') {
|
|
178
|
+
return mapping;
|
|
179
|
+
}
|
|
153
180
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
const schoolRepo = this.reflectionHelper.getRepoService('SSOSchool');
|
|
157
|
-
const schools = await schoolRepo.findOne({
|
|
158
|
-
where: {
|
|
159
|
-
brand_id: mapping.level_id
|
|
160
|
-
},
|
|
161
|
-
order: {
|
|
162
|
-
id: "ASC"
|
|
163
|
-
}
|
|
164
|
-
});
|
|
181
|
+
// Resolve SCH under BRN
|
|
182
|
+
const schoolRepo = this.reflectionHelper.getRepoService('SSOSchool');
|
|
165
183
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
}
|
|
184
|
+
const school = await schoolRepo.findOne({
|
|
185
|
+
where: {
|
|
186
|
+
brand_id: mapping.level_id,
|
|
187
|
+
},
|
|
188
|
+
order: { id: 'ASC' },
|
|
189
|
+
});
|
|
173
190
|
|
|
174
|
-
|
|
175
|
-
return
|
|
191
|
+
if (school) {
|
|
192
|
+
return {
|
|
193
|
+
...mapping,
|
|
194
|
+
level_type: 'SCH',
|
|
195
|
+
level_id: school.id,
|
|
196
|
+
};
|
|
176
197
|
}
|
|
198
|
+
|
|
199
|
+
// If no SCH found
|
|
200
|
+
return null;
|
|
201
|
+
}
|
|
202
|
+
|
|
177
203
|
}
|