emilsoftware-utilities 1.3.146 → 1.3.147
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/accessi-module/Controllers/UserController.d.ts +1 -1
- package/dist/accessi-module/Controllers/UserController.js +13 -4
- package/dist/accessi-module/Services/UserService/UserService.d.ts +7 -1
- package/dist/accessi-module/Services/UserService/UserService.js +21 -11
- package/package.json +1 -1
|
@@ -11,7 +11,7 @@ export declare class UserController {
|
|
|
11
11
|
private readonly logger;
|
|
12
12
|
constructor(userService: UserService, emailService: EmailService, options: AccessiOptions);
|
|
13
13
|
serveResetPasswordPage(res: Response, token: string): Promise<void>;
|
|
14
|
-
getUsers(res: Response, email?: string): Promise<Response<any, Record<string, any>>>;
|
|
14
|
+
getUsers(res: Response, email?: string, codiceUtente?: number, includeExtensionFields?: boolean, includeGrants?: boolean): Promise<Response<any, Record<string, any>>>;
|
|
15
15
|
deleteUser(codiceUtente: number, res: Response): Promise<Response<any, Record<string, any>>>;
|
|
16
16
|
register(request: Request, registrationData: RegisterRequest, res: Response): Promise<Response<any, Record<string, any>>>;
|
|
17
17
|
updateUtente(codiceUtente: number, user: UserDto, res: Response): Promise<Response<any, Record<string, any>>>;
|
|
@@ -46,14 +46,16 @@ let UserController = UserController_1 = class UserController {
|
|
|
46
46
|
return res.sendFile((0, path_1.join)(__dirname, '..', 'Views', 'reset-password.html'));
|
|
47
47
|
});
|
|
48
48
|
}
|
|
49
|
-
getUsers(res, email) {
|
|
49
|
+
getUsers(res, email, codiceUtente, includeExtensionFields, includeGrants) {
|
|
50
50
|
return __awaiter(this, void 0, void 0, function* () {
|
|
51
51
|
try {
|
|
52
|
-
|
|
52
|
+
let filters = { email, codiceUtente };
|
|
53
|
+
let options = { includeExtensionFields: includeExtensionFields !== null && includeExtensionFields !== void 0 ? includeExtensionFields : true, includeGrants: includeGrants !== null && includeGrants !== void 0 ? includeGrants : true };
|
|
54
|
+
const users = yield this.userService.getUsers(filters, options);
|
|
53
55
|
return Utilities_1.RestUtilities.sendBaseResponse(res, users);
|
|
54
56
|
}
|
|
55
57
|
catch (error) {
|
|
56
|
-
this.logger.error('Errore durante il recupero degli utenti', error);
|
|
58
|
+
this.logger.error('Errore durante il recupero degli utenti: ', error);
|
|
57
59
|
return Utilities_1.RestUtilities.sendErrorMessage(res, error, UserController_1.name);
|
|
58
60
|
}
|
|
59
61
|
});
|
|
@@ -125,11 +127,18 @@ __decorate([
|
|
|
125
127
|
(0, swagger_1.ApiOperation)({ summary: 'Recupera la lista degli utenti', operationId: "getUsers" }),
|
|
126
128
|
(0, swagger_1.ApiResponse)({ status: 200, description: 'Lista utenti recuperata con successo', type: GetUsersResponse_1.GetUsersResponse }),
|
|
127
129
|
(0, swagger_1.ApiResponse)({ status: 401, description: 'Credenziali non valide' }),
|
|
130
|
+
(0, swagger_1.ApiQuery)({ name: 'email', required: false, description: 'Email dell\'utente da cercare' }),
|
|
131
|
+
(0, swagger_1.ApiQuery)({ name: 'codiceUtente', required: false, description: "Codice dell'utente da cercare" }),
|
|
132
|
+
(0, swagger_1.ApiQuery)({ name: 'includeExtensionFields', required: false, description: "Includi extension fields (chiamata più pesante)" }),
|
|
133
|
+
(0, swagger_1.ApiQuery)({ name: 'includeGrants', required: false, description: "Includi Permessi (chiamata più pesante)" }),
|
|
128
134
|
(0, common_1.Get)('get-users'),
|
|
129
135
|
__param(0, (0, common_1.Res)()),
|
|
130
136
|
__param(1, (0, common_1.Query)('email')),
|
|
137
|
+
__param(2, (0, common_1.Query)('codiceUtente')),
|
|
138
|
+
__param(3, (0, common_1.Query)('includeExtensionFields', new common_1.ParseBoolPipe({ optional: true }))),
|
|
139
|
+
__param(4, (0, common_1.Query)('includeGrants', new common_1.ParseBoolPipe({ optional: true }))),
|
|
131
140
|
__metadata("design:type", Function),
|
|
132
|
-
__metadata("design:paramtypes", [Object, String]),
|
|
141
|
+
__metadata("design:paramtypes", [Object, String, Number, Boolean, Boolean]),
|
|
133
142
|
__metadata("design:returntype", Promise)
|
|
134
143
|
], UserController.prototype, "getUsers", null);
|
|
135
144
|
__decorate([
|
|
@@ -10,7 +10,13 @@ export declare class UserService {
|
|
|
10
10
|
private readonly emailService;
|
|
11
11
|
private readonly permissionService;
|
|
12
12
|
constructor(accessiOptions: AccessiOptions, emailService: EmailService, permissionService: PermissionService);
|
|
13
|
-
getUsers(
|
|
13
|
+
getUsers(filters?: {
|
|
14
|
+
email?: string;
|
|
15
|
+
codiceUtente?: number;
|
|
16
|
+
}, options?: {
|
|
17
|
+
includeExtensionFields: boolean;
|
|
18
|
+
includeGrants: boolean;
|
|
19
|
+
}): Promise<GetUsersResult[]>;
|
|
14
20
|
getCodiceUtenteByEmail(email: string): Promise<{
|
|
15
21
|
codiceUtente: number;
|
|
16
22
|
}>;
|
|
@@ -35,7 +35,7 @@ let UserService = class UserService {
|
|
|
35
35
|
this.emailService = emailService;
|
|
36
36
|
this.permissionService = permissionService;
|
|
37
37
|
}
|
|
38
|
-
getUsers(
|
|
38
|
+
getUsers(filters, options) {
|
|
39
39
|
return __awaiter(this, void 0, void 0, function* () {
|
|
40
40
|
try {
|
|
41
41
|
let query = `
|
|
@@ -66,25 +66,34 @@ let UserService = class UserService {
|
|
|
66
66
|
F.CODCLIENTI AS codice_clienti,
|
|
67
67
|
F.TIPFIL AS tip_fil
|
|
68
68
|
FROM UTENTI U
|
|
69
|
+
INNER JOIN UTENTI_CONFIG G ON U.CODUTE = G.CODUTE
|
|
70
|
+
LEFT JOIN FILTRI F ON F.CODUTE = U.CODUTE
|
|
69
71
|
WHERE 1=1
|
|
70
72
|
`;
|
|
71
73
|
let queryParams = [];
|
|
72
|
-
if (email) {
|
|
74
|
+
if (filters.email) {
|
|
73
75
|
query += ` AND LOWER(U.USRNAME) = ? `;
|
|
74
|
-
queryParams.push(email.trim().toLowerCase());
|
|
76
|
+
queryParams.push(filters.email.trim().toLowerCase());
|
|
75
77
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
78
|
+
if (filters.codiceUtente) {
|
|
79
|
+
query += ` AND U.CODUTE = ? `;
|
|
80
|
+
queryParams.push(filters.codiceUtente);
|
|
81
|
+
}
|
|
82
|
+
query += ` ORDER BY U.CODUTE DESC `;
|
|
79
83
|
let users = yield Orm_1.Orm.query(this.accessiOptions.databaseOptions, query, queryParams);
|
|
80
84
|
users = users.map(Utilities_1.RestUtilities.convertKeysToCamelCase);
|
|
81
85
|
let usersResponse = [];
|
|
86
|
+
console.log("OPTIONS: ", options);
|
|
82
87
|
for (const user of users) {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
+
let userGrants = null;
|
|
89
|
+
if (options.includeGrants)
|
|
90
|
+
userGrants = yield this.permissionService.getUserRolesAndGrants(user.codiceUtente);
|
|
91
|
+
let extensionFields = options.includeExtensionFields ? {} : null;
|
|
92
|
+
if (options.includeExtensionFields) {
|
|
93
|
+
for (const ext of this.accessiOptions.extensionFieldsOptions) {
|
|
94
|
+
const values = (yield Orm_1.Orm.query(ext.databaseOptions, `SELECT ${ext.tableFields.join(",")} FROM ${ext.tableName} WHERE ${ext.tableJoinFieldName} = ?`, [user.codiceUtente])).map(Utilities_1.RestUtilities.convertKeysToCamelCase);
|
|
95
|
+
extensionFields[ext.objectKey] = values;
|
|
96
|
+
}
|
|
88
97
|
}
|
|
89
98
|
let userResult = {
|
|
90
99
|
utente: user,
|
|
@@ -93,6 +102,7 @@ let UserService = class UserService {
|
|
|
93
102
|
};
|
|
94
103
|
usersResponse.push(userResult);
|
|
95
104
|
}
|
|
105
|
+
console.log("OPTIONS: ", options);
|
|
96
106
|
return usersResponse;
|
|
97
107
|
}
|
|
98
108
|
catch (error) {
|