rez_core 2.0.60 → 2.0.62
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/filter/controller/filter.controller.d.ts +3 -1
- package/dist/module/filter/controller/filter.controller.js +8 -2
- package/dist/module/filter/controller/filter.controller.js.map +1 -1
- package/dist/module/filter/dto/filter-request.dto.d.ts +2 -0
- package/dist/module/filter/service/filter.service.js +1 -1
- package/dist/module/filter/service/filter.service.js.map +1 -1
- package/dist/module/meta/service/entity-service-impl.service.js +4 -0
- package/dist/module/meta/service/entity-service-impl.service.js.map +1 -1
- package/dist/module/user/service/login.service.d.ts +4 -0
- package/dist/module/user/service/login.service.js +2 -0
- package/dist/module/user/service/login.service.js.map +1 -1
- package/dist/module/user/service/user-session.service.d.ts +2 -0
- package/dist/module/user/service/user-session.service.js +2 -0
- 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/filter/controller/filter.controller.ts +8 -0
- package/src/module/filter/dto/filter-request.dto.ts +2 -0
- package/src/module/filter/service/filter.service.ts +2 -0
- package/src/module/meta/service/entity-service-impl.service.ts +3 -0
- package/src/module/user/service/login.service.ts +6 -8
- package/src/module/user/service/user-session.service.ts +9 -103
package/package.json
CHANGED
|
@@ -7,9 +7,12 @@ import {
|
|
|
7
7
|
Get,
|
|
8
8
|
Param,
|
|
9
9
|
Inject,
|
|
10
|
+
UseGuards,
|
|
11
|
+
Req,
|
|
10
12
|
} from '@nestjs/common';
|
|
11
13
|
import { FilterService } from '../service/filter.service';
|
|
12
14
|
import { SavedFilterService } from '../service/saved-filter.service';
|
|
15
|
+
import { JwtAuthGuard } from 'src/module/auth/guards/jwt.guard';
|
|
13
16
|
|
|
14
17
|
@Controller('filter')
|
|
15
18
|
export class FilterController {
|
|
@@ -20,11 +23,14 @@ export class FilterController {
|
|
|
20
23
|
) {}
|
|
21
24
|
|
|
22
25
|
@Post()
|
|
26
|
+
@UseGuards(JwtAuthGuard)
|
|
23
27
|
async applyFilter(
|
|
24
28
|
@Body() body: any,
|
|
25
29
|
@Query('page', ParseIntPipe) page: number = 1,
|
|
26
30
|
@Query('size', ParseIntPipe) size: number = 10,
|
|
31
|
+
@Req() req: Request & { user: any },
|
|
27
32
|
) {
|
|
33
|
+
const userData = req.user.userData;
|
|
28
34
|
const {
|
|
29
35
|
entity_type,
|
|
30
36
|
quickFilter,
|
|
@@ -43,6 +49,8 @@ export class FilterController {
|
|
|
43
49
|
sortby,
|
|
44
50
|
page,
|
|
45
51
|
size,
|
|
52
|
+
level_type: userData.level_type,
|
|
53
|
+
level_id: userData.level_id,
|
|
46
54
|
});
|
|
47
55
|
}
|
|
48
56
|
|
|
@@ -82,6 +82,9 @@ export class EntityServiceImpl implements EntityService<BaseEntity> {
|
|
|
82
82
|
entityData.organization_id = loggedInUser.organization_id;
|
|
83
83
|
if (!entityData.enterprise_id)
|
|
84
84
|
entityData.enterprise_id = loggedInUser.enterprise_id;
|
|
85
|
+
if (!entityData.level_type)
|
|
86
|
+
entityData.level_type = loggedInUser.level_type;
|
|
87
|
+
if (!entityData.level_id) entityData.level_id = loggedInUser.level_id;
|
|
85
88
|
}
|
|
86
89
|
|
|
87
90
|
return repo.save(entityData);
|
|
@@ -87,14 +87,10 @@ export class LoginService {
|
|
|
87
87
|
await this.userService.setDefaultLastAccess(user.id, appcode);
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
-
const token = await this.userSessionService.createSession(
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
level_type: defaultAccess.level_type,
|
|
95
|
-
level_id: defaultAccess.level_id,
|
|
96
|
-
},
|
|
97
|
-
);
|
|
90
|
+
const token = await this.userSessionService.createSession(user, appcode, {
|
|
91
|
+
level_type: defaultAccess.level_type,
|
|
92
|
+
level_id: defaultAccess.level_id,
|
|
93
|
+
});
|
|
98
94
|
|
|
99
95
|
if (user.is_firstlogin === 1) {
|
|
100
96
|
user.invitation_status = 'ACCEPTED';
|
|
@@ -107,6 +103,8 @@ export class LoginService {
|
|
|
107
103
|
success: true,
|
|
108
104
|
accessToken: token,
|
|
109
105
|
appcode,
|
|
106
|
+
level_type: defaultAccess.level_type,
|
|
107
|
+
level_id: defaultAccess.level_id,
|
|
110
108
|
};
|
|
111
109
|
}
|
|
112
110
|
|
|
@@ -67,24 +67,15 @@ export class UserSessionService {
|
|
|
67
67
|
async switchCurrentLevelService(
|
|
68
68
|
currentUser: any,
|
|
69
69
|
data: any,
|
|
70
|
-
): Promise<{
|
|
70
|
+
): Promise<{
|
|
71
|
+
success: boolean;
|
|
72
|
+
access_token: string;
|
|
73
|
+
appcode: string;
|
|
74
|
+
level_type: string;
|
|
75
|
+
level_id: string;
|
|
76
|
+
}> {
|
|
71
77
|
let payload;
|
|
72
78
|
|
|
73
|
-
// Step 1: App-level access check
|
|
74
|
-
// if (data.appcode) {
|
|
75
|
-
// console.log('in appcode check', data.appcode);
|
|
76
|
-
|
|
77
|
-
// const userApp = await this.userRoleMappingService.getUserByIdAndAppCode(
|
|
78
|
-
// userId,
|
|
79
|
-
// data.appcode,
|
|
80
|
-
// );
|
|
81
|
-
|
|
82
|
-
// if (!userApp) {
|
|
83
|
-
// throw new BadRequestException(
|
|
84
|
-
// 'User does not have access to this appcode',
|
|
85
|
-
// );
|
|
86
|
-
// }
|
|
87
|
-
|
|
88
79
|
payload = {
|
|
89
80
|
...currentUser,
|
|
90
81
|
level_id: data.level_id,
|
|
@@ -97,97 +88,12 @@ export class UserSessionService {
|
|
|
97
88
|
[data.appcode, currentUser.id],
|
|
98
89
|
);
|
|
99
90
|
|
|
100
|
-
// }
|
|
101
|
-
|
|
102
|
-
// Step 2: Level switch logic
|
|
103
|
-
// if (data.level_id && data.level_type) {
|
|
104
|
-
// console.log(
|
|
105
|
-
// 'in level_id and level_type check',
|
|
106
|
-
// data.level_id,
|
|
107
|
-
// data.level_type,
|
|
108
|
-
// );
|
|
109
|
-
|
|
110
|
-
// console.log(
|
|
111
|
-
// 'Current User Level Type:',
|
|
112
|
-
// currentUserLevelType,
|
|
113
|
-
// 'Current User Level ID:',
|
|
114
|
-
// currentUserLevelId,
|
|
115
|
-
// );
|
|
116
|
-
|
|
117
|
-
// const hasAccess = await this.dataSource.query(
|
|
118
|
-
// 'SELECT * FROM cr_user_role_mapping WHERE user_id = ? AND level_type = ? AND level_id = ? AND appcode = ?',
|
|
119
|
-
// [userId, data.level_type, data.level_id, data.appcode || null],
|
|
120
|
-
// );
|
|
121
|
-
|
|
122
|
-
// console.log('Has Access:', hasAccess);
|
|
123
|
-
|
|
124
|
-
// // check if hasAccess is non-empty
|
|
125
|
-
// if (hasAccess.length) {
|
|
126
|
-
// payload = {
|
|
127
|
-
// id: userId,
|
|
128
|
-
// level_id: data.level_id,
|
|
129
|
-
// level_type: data.level_type,
|
|
130
|
-
// appcode: data.appcode || null,
|
|
131
|
-
// };
|
|
132
|
-
// }
|
|
133
|
-
// } else if (currentUserLevelType === 'ORG') {
|
|
134
|
-
// const school = await this.dataSource.query(
|
|
135
|
-
// 'SELECT * FROM cr_school WHERE id = ?',
|
|
136
|
-
// [data.level_id],
|
|
137
|
-
// );
|
|
138
|
-
|
|
139
|
-
// console.log('Current User Org ID:', currentUserOrgId);
|
|
140
|
-
// console.log('Data Level Type:', data.level_type);
|
|
141
|
-
// console.log('School:', school);
|
|
142
|
-
|
|
143
|
-
// if (!school.length || currentUserOrgId !== school[0].organization_id) {
|
|
144
|
-
// throw new BadRequestException(
|
|
145
|
-
// 'You do not have access to this school',
|
|
146
|
-
// );
|
|
147
|
-
// }
|
|
148
|
-
|
|
149
|
-
// payload = {
|
|
150
|
-
// id: userId,
|
|
151
|
-
// level_id: data.level_id,
|
|
152
|
-
// level_type: data.level_type,
|
|
153
|
-
// appcode: data.appcode || null,
|
|
154
|
-
// };
|
|
155
|
-
// } else if (currentUserLevelType === 'BRN') {
|
|
156
|
-
// console.log('Current User Level Type is BRN');
|
|
157
|
-
|
|
158
|
-
// const school = await this.dataSource.query(
|
|
159
|
-
// 'SELECT * FROM cr_school WHERE id = ?',
|
|
160
|
-
// [data.level_id],
|
|
161
|
-
// );
|
|
162
|
-
|
|
163
|
-
// console.log('school:', school);
|
|
164
|
-
|
|
165
|
-
// if (!school.length || school[0].brand_id !== currentUserLevelId) {
|
|
166
|
-
// throw new BadRequestException(
|
|
167
|
-
// 'You do not have access to this school',
|
|
168
|
-
// );
|
|
169
|
-
// }
|
|
170
|
-
|
|
171
|
-
// payload = {
|
|
172
|
-
// id: userId,
|
|
173
|
-
// level_id: data.level_id,
|
|
174
|
-
// level_type: data.level_type,
|
|
175
|
-
// appcode: data.appcode || null,
|
|
176
|
-
// };
|
|
177
|
-
// }
|
|
178
|
-
// else {
|
|
179
|
-
// throw new BadRequestException('You do not have access to this level');
|
|
180
|
-
// }
|
|
181
|
-
// }
|
|
182
|
-
|
|
183
|
-
// if (!payload) {
|
|
184
|
-
// throw new BadRequestException('Invalid request parameters');
|
|
185
|
-
// }
|
|
186
|
-
|
|
187
91
|
return {
|
|
188
92
|
success: true,
|
|
189
93
|
access_token: this.jwtAuthService.generateJwt(payload),
|
|
190
94
|
appcode: data.appcode,
|
|
95
|
+
level_type: data.level_type,
|
|
96
|
+
level_id: data.level_id,
|
|
191
97
|
};
|
|
192
98
|
}
|
|
193
99
|
}
|