rez_core 5.0.135 → 5.0.136
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/user/service/user-session.service.js +12 -11
- 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/module/user/service/user-session.service.ts +64 -67
- package/.idea/inspectionProfiles/Project_Default.xml +0 -6
- package/.idea/prettier.xml +0 -6
package/package.json
CHANGED
|
@@ -71,6 +71,7 @@ export class UserSessionService {
|
|
|
71
71
|
await this.userSessionRepository.saveSession(userSession);
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
+
|
|
74
75
|
async switchCurrentLevelService(
|
|
75
76
|
currentUser: any,
|
|
76
77
|
data: any,
|
|
@@ -122,82 +123,78 @@ export class UserSessionService {
|
|
|
122
123
|
}
|
|
123
124
|
|
|
124
125
|
async checkIfUserHasMapping(
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
): Promise<boolean> {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
}
|
|
153
|
-
|
|
126
|
+
userId: number,
|
|
127
|
+
appcode: string,
|
|
128
|
+
levelType: string,
|
|
129
|
+
levelId: string,
|
|
130
|
+
): Promise<boolean> {
|
|
131
|
+
// Get repositories dynamically via reflectionHelper
|
|
132
|
+
const userRoleMappingRepo =
|
|
133
|
+
this.reflectionHelper.getRepoService('UserRoleMapping');
|
|
134
|
+
const appMasterRepo = 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
|
+
}
|
|
154
153
|
|
|
155
154
|
async getUserRoleMappingForApp(userId: number, appcode: string) {
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
this.reflectionHelper.getRepoService('
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
'
|
|
169
|
-
'app.
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
if (!mapping || mapping.level_type !== 'BRN') {
|
|
178
|
-
return mapping;
|
|
179
|
-
}
|
|
155
|
+
const userRoleMappingRepo =
|
|
156
|
+
this.reflectionHelper.getRepoService('UserRoleMapping');
|
|
157
|
+
const appMasterRepo = this.reflectionHelper.getRepoService('AppMaster');
|
|
158
|
+
|
|
159
|
+
const mapping = await userRoleMappingRepo
|
|
160
|
+
.createQueryBuilder('urm')
|
|
161
|
+
.innerJoin(
|
|
162
|
+
appMasterRepo.metadata.tableName,
|
|
163
|
+
'app',
|
|
164
|
+
'app.appcode = urm.appcode',
|
|
165
|
+
)
|
|
166
|
+
.where('urm.user_id = :userId', { userId })
|
|
167
|
+
.andWhere('urm.appcode = :appcode', { appcode })
|
|
168
|
+
.andWhere('app.show_in_ui = true')
|
|
169
|
+
.getOne();
|
|
170
|
+
|
|
171
|
+
if (!mapping) {
|
|
172
|
+
throw new BadRequestException(
|
|
173
|
+
`User does not have visible access to app ${appcode}`,
|
|
174
|
+
);
|
|
175
|
+
}
|
|
180
176
|
|
|
181
|
-
|
|
182
|
-
|
|
177
|
+
if (mapping.level_type !== 'BRN') {
|
|
178
|
+
return mapping;
|
|
179
|
+
}
|
|
183
180
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
181
|
+
// Resolve SCH under brand
|
|
182
|
+
const schoolRepo = this.reflectionHelper.getRepoService('SSOSchool');
|
|
183
|
+
const school = await schoolRepo.findOne({
|
|
184
|
+
where: { brand_id: mapping.level_id },
|
|
185
|
+
order: { id: 'ASC' },
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
if (!school) {
|
|
189
|
+
throw new BadRequestException(
|
|
190
|
+
`No schools found under brand ${mapping.level_id}`,
|
|
191
|
+
);
|
|
192
|
+
}
|
|
190
193
|
|
|
191
|
-
if (school) {
|
|
192
194
|
return {
|
|
193
195
|
...mapping,
|
|
194
196
|
level_type: 'SCH',
|
|
195
197
|
level_id: school.id,
|
|
196
198
|
};
|
|
197
199
|
}
|
|
198
|
-
|
|
199
|
-
// If no SCH found
|
|
200
|
-
return null;
|
|
201
|
-
}
|
|
202
|
-
|
|
203
200
|
}
|