emilsoftware-utilities 1.3.97 → 1.3.99
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/AccessiModule.js +2 -1
- package/dist/accessi-module/Controllers/AccessiController.d.ts +3 -4
- package/dist/accessi-module/Controllers/AccessiController.js +4 -23
- package/dist/accessi-module/Controllers/AuthController.d.ts +1 -1
- package/dist/accessi-module/Controllers/AuthController.js +17 -0
- package/dist/accessi-module/Controllers/EmailController.d.ts +1 -1
- package/dist/accessi-module/Controllers/EmailController.js +8 -2
- package/dist/accessi-module/Controllers/PermissionController.d.ts +14 -2
- package/dist/accessi-module/Controllers/PermissionController.js +223 -14
- package/dist/accessi-module/Controllers/UserController.d.ts +17 -0
- package/dist/accessi-module/Controllers/UserController.js +211 -0
- package/dist/accessi-module/Dtos/Abilitazione.d.ts +6 -0
- package/dist/accessi-module/Dtos/Abilitazione.js +47 -0
- package/dist/accessi-module/Dtos/AbilitazioneMenu.d.ts +11 -0
- package/dist/accessi-module/Dtos/AbilitazioneMenu.js +91 -0
- package/dist/accessi-module/Dtos/AssignPermissionsToUserRequest.d.ts +4 -0
- package/dist/accessi-module/Dtos/AssignPermissionsToUserRequest.js +28 -0
- package/dist/accessi-module/Dtos/AssignRolesToUserRequest.d.ts +3 -0
- package/dist/accessi-module/Dtos/AssignRolesToUserRequest.js +24 -0
- package/dist/accessi-module/Dtos/FiltriUtente.d.ts +10 -0
- package/dist/accessi-module/Dtos/FiltriUtente.js +87 -0
- package/dist/accessi-module/Dtos/GetMenusResponse.d.ts +12 -0
- package/dist/accessi-module/Dtos/GetMenusResponse.js +80 -0
- package/dist/accessi-module/{models/QueryResults/UserQueryResult.d.ts → Dtos/GetUsersResponse.d.ts} +2 -2
- package/dist/accessi-module/Dtos/GetUsersResponse.js +252 -0
- package/dist/accessi-module/Dtos/LoginRequest.d.ts +4 -0
- package/dist/accessi-module/Dtos/LoginRequest.js +35 -0
- package/dist/accessi-module/Dtos/LoginResult.d.ts +10 -0
- package/dist/accessi-module/Dtos/LoginResult.js +34 -0
- package/dist/accessi-module/Dtos/MenuItem.d.ts +0 -0
- package/dist/accessi-module/Dtos/MenuItem.js +0 -0
- package/dist/accessi-module/Dtos/Permission.d.ts +4 -0
- package/dist/accessi-module/Dtos/Permission.js +32 -0
- package/dist/accessi-module/Dtos/Role.d.ts +12 -0
- package/dist/accessi-module/Dtos/Role.js +50 -0
- package/dist/accessi-module/Dtos/TipoAbilitazione.d.ts +6 -0
- package/dist/accessi-module/{Services/PermissionService/IPermissionService.js → Dtos/TipoAbilitazione.js} +1 -1
- package/dist/accessi-module/Dtos/TokenResult.d.ts +5 -0
- package/dist/accessi-module/Dtos/TokenResult.js +38 -0
- package/dist/accessi-module/Dtos/User.d.ts +19 -0
- package/dist/accessi-module/Dtos/User.js +118 -0
- package/dist/accessi-module/Dtos/index.d.ts +13 -0
- package/dist/accessi-module/Dtos/index.js +29 -0
- package/dist/accessi-module/Services/AuthService/AuthService.d.ts +6 -5
- package/dist/accessi-module/Services/AuthService/AuthService.js +39 -23
- package/dist/accessi-module/Services/EmailService/EmailService.d.ts +1 -2
- package/dist/accessi-module/Services/EmailService/EmailService.js +1 -1
- package/dist/accessi-module/Services/PermissionService/PermissionService.d.ts +12 -5
- package/dist/accessi-module/Services/PermissionService/PermissionService.js +143 -5
- package/dist/accessi-module/Services/UserService/UserService.d.ts +11 -10
- package/dist/accessi-module/Services/UserService/UserService.js +20 -15
- package/dist/accessi-module/index.d.ts +1 -3
- package/dist/accessi-module/index.js +32 -15
- package/dist/accessi-module/swagger/SwaggerConfig.js +3 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -4
- package/package.json +1 -1
- package/dist/accessi-module/Services/AuthService/IAuthService.d.ts +0 -64
- package/dist/accessi-module/Services/AuthService/IAuthService.js +0 -2
- package/dist/accessi-module/Services/EmailService/IEmailService.d.ts +0 -21
- package/dist/accessi-module/Services/EmailService/IEmailService.js +0 -2
- package/dist/accessi-module/Services/PermissionService/IPermissionService.d.ts +0 -59
- package/dist/accessi-module/Services/UserService/IUserService.d.ts +0 -110
- package/dist/accessi-module/Services/UserService/IUserService.js +0 -2
- package/dist/accessi-module/models/QueryResults/MenuAbilitazioniResult.d.ts +0 -11
- package/dist/accessi-module/models/QueryResults/MenuAbilitazioniResult.js +0 -2
- package/dist/accessi-module/models/QueryResults/UserQueryResult.js +0 -2
- /package/dist/accessi-module/{models → Dtos}/StatoRegistrazione.d.ts +0 -0
- /package/dist/accessi-module/{models → Dtos}/StatoRegistrazione.js +0 -0
|
@@ -17,6 +17,7 @@ const UserService_1 = require("./Services/UserService/UserService");
|
|
|
17
17
|
const EmailController_1 = require("./Controllers/EmailController");
|
|
18
18
|
const AuthController_1 = require("./Controllers/AuthController");
|
|
19
19
|
const PermissionController_1 = require("./Controllers/PermissionController");
|
|
20
|
+
const UserController_1 = require("./Controllers/UserController");
|
|
20
21
|
let AccessiModule = AccessiModule_1 = class AccessiModule {
|
|
21
22
|
static forRoot(options) {
|
|
22
23
|
return {
|
|
@@ -39,7 +40,7 @@ exports.AccessiModule = AccessiModule;
|
|
|
39
40
|
exports.AccessiModule = AccessiModule = AccessiModule_1 = __decorate([
|
|
40
41
|
(0, common_1.Global)(),
|
|
41
42
|
(0, common_1.Module)({
|
|
42
|
-
controllers: [AccessiController_1.AccessiController, EmailController_1.EmailController, AuthController_1.AuthController, PermissionController_1.PermissionController],
|
|
43
|
+
controllers: [AccessiController_1.AccessiController, EmailController_1.EmailController, AuthController_1.AuthController, PermissionController_1.PermissionController, UserController_1.UserController],
|
|
43
44
|
providers: [AuthService_1.AuthService, UserService_1.UserService, EmailService_1.EmailService, PermissionService_1.PermissionService],
|
|
44
45
|
exports: [AuthService_1.AuthService, UserService_1.UserService, EmailService_1.EmailService, PermissionService_1.PermissionService],
|
|
45
46
|
})
|
|
@@ -4,7 +4,7 @@ import { AuthService } from '../Services/AuthService/AuthService';
|
|
|
4
4
|
import { PermissionService } from '../Services/PermissionService/PermissionService';
|
|
5
5
|
import { UserService } from '../Services/UserService/UserService';
|
|
6
6
|
import { EmailService } from '../Services/EmailService/EmailService';
|
|
7
|
-
import {
|
|
7
|
+
import { User } from '../Dtos';
|
|
8
8
|
export declare class AccessiController {
|
|
9
9
|
private readonly userService;
|
|
10
10
|
private readonly authService;
|
|
@@ -16,12 +16,12 @@ export declare class AccessiController {
|
|
|
16
16
|
resetPassword(res: Response, token: string, newPassword: string): Promise<Response<any, Record<string, any>>>;
|
|
17
17
|
getUserByToken(token: string, res: Response): Promise<Response<any, Record<string, any>>>;
|
|
18
18
|
login(loginDto: {
|
|
19
|
-
|
|
19
|
+
email: string;
|
|
20
20
|
password: string;
|
|
21
21
|
}, res: Response): Promise<Response<any, Record<string, any>>>;
|
|
22
22
|
getUsers(res: Response): Promise<Response<any, Record<string, any>>>;
|
|
23
23
|
deleteUser(codiceUtente: string, res: Response): Promise<Response<any, Record<string, any>>>;
|
|
24
|
-
register(request: Request, registrationData:
|
|
24
|
+
register(request: Request, registrationData: User, res: Response): Promise<Response<any, Record<string, any>>>;
|
|
25
25
|
encrypt(data: string, res: Response): Promise<Response<any, Record<string, any>>>;
|
|
26
26
|
decrypt(data: string, res: Response): Promise<Response<any, Record<string, any>>>;
|
|
27
27
|
resetAbilitazioni(codiceUtente: string, res: Response): Promise<Response<any, Record<string, any>>>;
|
|
@@ -29,6 +29,5 @@ export declare class AccessiController {
|
|
|
29
29
|
codiceUtente: string;
|
|
30
30
|
nuovaPassword: string;
|
|
31
31
|
}, res: Response): Promise<Response<any, Record<string, any>>>;
|
|
32
|
-
updateUtente(user: any, res: Response): Promise<Response<any, Record<string, any>>>;
|
|
33
32
|
setGdpr(codiceUtente: string, res: Response): Promise<Response<any, Record<string, any>>>;
|
|
34
33
|
}
|
|
@@ -65,6 +65,7 @@ const PermissionService_1 = require("../Services/PermissionService/PermissionSer
|
|
|
65
65
|
const UserService_1 = require("../Services/UserService/UserService");
|
|
66
66
|
const EmailService_1 = require("../Services/EmailService/EmailService");
|
|
67
67
|
const path_1 = require("path");
|
|
68
|
+
const Dtos_1 = require("../Dtos");
|
|
68
69
|
let AccessiController = AccessiController_1 = class AccessiController {
|
|
69
70
|
constructor(userService, authService, emailService, permissionService, options) {
|
|
70
71
|
this.userService = userService;
|
|
@@ -156,7 +157,7 @@ let AccessiController = AccessiController_1 = class AccessiController {
|
|
|
156
157
|
}
|
|
157
158
|
yield this.userService.register(registrationData);
|
|
158
159
|
let confirmationEmailPrefix = protocol + "://" + host;
|
|
159
|
-
yield this.emailService.sendPasswordResetEmail(registrationData.
|
|
160
|
+
yield this.emailService.sendPasswordResetEmail(registrationData.email, confirmationEmailPrefix);
|
|
160
161
|
return Utilities_1.RestUtilities.sendOKMessage(res, "L'utente è stato registrato con successo, email di conferma inoltrata al destinatario.");
|
|
161
162
|
}
|
|
162
163
|
catch (error) {
|
|
@@ -208,17 +209,6 @@ let AccessiController = AccessiController_1 = class AccessiController {
|
|
|
208
209
|
}
|
|
209
210
|
});
|
|
210
211
|
}
|
|
211
|
-
updateUtente(user, res) {
|
|
212
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
213
|
-
try {
|
|
214
|
-
yield this.userService.updateUser(user);
|
|
215
|
-
return Utilities_1.RestUtilities.sendOKMessage(res, `L'utente ${user.codiceUtente} è stato aggiornato con successo.`);
|
|
216
|
-
}
|
|
217
|
-
catch (error) {
|
|
218
|
-
return Utilities_1.RestUtilities.sendErrorMessage(res, error, AccessiController_1.name);
|
|
219
|
-
}
|
|
220
|
-
});
|
|
221
|
-
}
|
|
222
212
|
setGdpr(codiceUtente, res) {
|
|
223
213
|
return __awaiter(this, void 0, void 0, function* () {
|
|
224
214
|
try {
|
|
@@ -291,7 +281,7 @@ __decorate([
|
|
|
291
281
|
__param(1, (0, common_1.Body)()),
|
|
292
282
|
__param(2, (0, common_1.Res)()),
|
|
293
283
|
__metadata("design:type", Function),
|
|
294
|
-
__metadata("design:paramtypes", [Request,
|
|
284
|
+
__metadata("design:paramtypes", [Request, Dtos_1.User, Object]),
|
|
295
285
|
__metadata("design:returntype", Promise)
|
|
296
286
|
], AccessiController.prototype, "register", null);
|
|
297
287
|
__decorate([
|
|
@@ -330,15 +320,6 @@ __decorate([
|
|
|
330
320
|
__metadata("design:paramtypes", [Object, Object]),
|
|
331
321
|
__metadata("design:returntype", Promise)
|
|
332
322
|
], AccessiController.prototype, "setPassword", null);
|
|
333
|
-
__decorate([
|
|
334
|
-
(0, swagger_1.ApiOperation)({ summary: 'Aggiorna un utente esistente' }),
|
|
335
|
-
(0, common_1.Post)('update-utente'),
|
|
336
|
-
__param(0, (0, common_1.Body)()),
|
|
337
|
-
__param(1, (0, common_1.Res)()),
|
|
338
|
-
__metadata("design:type", Function),
|
|
339
|
-
__metadata("design:paramtypes", [Object, Object]),
|
|
340
|
-
__metadata("design:returntype", Promise)
|
|
341
|
-
], AccessiController.prototype, "updateUtente", null);
|
|
342
323
|
__decorate([
|
|
343
324
|
(0, swagger_1.ApiOperation)({ summary: 'Imposta il consenso GDPR' }),
|
|
344
325
|
(0, common_1.Post)('set-gdpr'),
|
|
@@ -350,7 +331,7 @@ __decorate([
|
|
|
350
331
|
], AccessiController.prototype, "setGdpr", null);
|
|
351
332
|
exports.AccessiController = AccessiController = AccessiController_1 = __decorate([
|
|
352
333
|
(0, Utilities_1.Deprecated)("AccessiController è deprecato. Usa i controller specifici per ogni area."),
|
|
353
|
-
(0, swagger_1.ApiTags)('
|
|
334
|
+
(0, swagger_1.ApiTags)('AccessiDEPRECATED'),
|
|
354
335
|
(0, common_1.Controller)('accessi'),
|
|
355
336
|
__param(4, (0, common_1.Inject)('ACCESSI_OPTIONS')),
|
|
356
337
|
__metadata("design:paramtypes", [UserService_1.UserService,
|
|
@@ -8,7 +8,7 @@ export declare class AuthController {
|
|
|
8
8
|
resetPassword(res: Response, token: string, newPassword: string): Promise<Response<any, Record<string, any>>>;
|
|
9
9
|
getUserByToken(token: string, res: Response): Promise<Response<any, Record<string, any>>>;
|
|
10
10
|
login(loginDto: {
|
|
11
|
-
|
|
11
|
+
email: string;
|
|
12
12
|
password: string;
|
|
13
13
|
}, res: Response): Promise<Response<any, Record<string, any>>>;
|
|
14
14
|
}
|
|
@@ -114,6 +114,10 @@ let AuthController = AuthController_1 = class AuthController {
|
|
|
114
114
|
exports.AuthController = AuthController;
|
|
115
115
|
__decorate([
|
|
116
116
|
(0, swagger_1.ApiOperation)({ summary: 'Conferma il reset della password' }),
|
|
117
|
+
(0, swagger_1.ApiParam)({ name: 'token', description: 'Token per il reset della password', required: true }),
|
|
118
|
+
(0, swagger_1.ApiBody)({ schema: { properties: { newPassword: { type: 'string', description: 'Nuova password da impostare' } } } }),
|
|
119
|
+
(0, swagger_1.ApiResponse)({ status: 200, description: 'Password aggiornata con successo' }),
|
|
120
|
+
(0, swagger_1.ApiResponse)({ status: 400, description: 'Errore nella richiesta o token non valido' }),
|
|
117
121
|
(0, common_1.Post)('confirm-reset-password/:token'),
|
|
118
122
|
__param(0, (0, common_1.Res)()),
|
|
119
123
|
__param(1, (0, common_1.Param)('token')),
|
|
@@ -124,6 +128,9 @@ __decorate([
|
|
|
124
128
|
], AuthController.prototype, "resetPassword", null);
|
|
125
129
|
__decorate([
|
|
126
130
|
(0, swagger_1.ApiOperation)({ summary: 'Recupera le informazioni utente dal token JWT' }),
|
|
131
|
+
(0, swagger_1.ApiBody)({ schema: { properties: { token: { type: 'string', description: 'JWT dell\'utente' } } } }),
|
|
132
|
+
(0, swagger_1.ApiResponse)({ status: 200, description: 'Informazioni utente recuperate con successo' }),
|
|
133
|
+
(0, swagger_1.ApiResponse)({ status: 401, description: 'Token non valido o scaduto' }),
|
|
127
134
|
(0, common_1.Post)('get-user-by-token'),
|
|
128
135
|
__param(0, (0, common_1.Body)('token')),
|
|
129
136
|
__param(1, (0, common_1.Res)()),
|
|
@@ -133,6 +140,16 @@ __decorate([
|
|
|
133
140
|
], AuthController.prototype, "getUserByToken", null);
|
|
134
141
|
__decorate([
|
|
135
142
|
(0, swagger_1.ApiOperation)({ summary: 'Effettua il login' }),
|
|
143
|
+
(0, swagger_1.ApiBody)({
|
|
144
|
+
schema: {
|
|
145
|
+
properties: {
|
|
146
|
+
email: { type: 'string', description: 'Email dell\'utente' },
|
|
147
|
+
password: { type: 'string', description: 'Password dell\'utente' }
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}),
|
|
151
|
+
(0, swagger_1.ApiResponse)({ status: 200, description: 'Login effettuato con successo' }),
|
|
152
|
+
(0, swagger_1.ApiResponse)({ status: 401, description: 'Credenziali non valide' }),
|
|
136
153
|
(0, common_1.Post)('login'),
|
|
137
154
|
__param(0, (0, common_1.Body)()),
|
|
138
155
|
__param(1, (0, common_1.Res)()),
|
|
@@ -46,7 +46,7 @@ let EmailController = class EmailController {
|
|
|
46
46
|
if (!protocol || !host) {
|
|
47
47
|
return Utilities_1.RestUtilities.sendErrorMessage(res, "Impossibile procedere: protocollo e host non impostati negli header della richiesta.", AccessiController_1.AccessiController.name);
|
|
48
48
|
}
|
|
49
|
-
let confirmationEmailPrefix = protocol
|
|
49
|
+
let confirmationEmailPrefix = `${protocol}://${host}`;
|
|
50
50
|
yield this.emailService.sendPasswordResetEmail(sendResetPasswordData.email, confirmationEmailPrefix);
|
|
51
51
|
return Utilities_1.RestUtilities.sendOKMessage(res, "L'email di reset è stata inoltrata al destinatario.");
|
|
52
52
|
}
|
|
@@ -59,6 +59,8 @@ let EmailController = class EmailController {
|
|
|
59
59
|
exports.EmailController = EmailController;
|
|
60
60
|
__decorate([
|
|
61
61
|
(0, swagger_1.ApiOperation)({ summary: 'Serve una pagina per il reset della password' }),
|
|
62
|
+
(0, swagger_1.ApiParam)({ name: 'token', description: 'Token per il reset della password', required: true }),
|
|
63
|
+
(0, swagger_1.ApiResponse)({ status: 200, description: 'Pagina di reset password servita con successo' }),
|
|
62
64
|
(0, common_1.Get)('reset-password-page/:token'),
|
|
63
65
|
__param(0, (0, common_1.Res)()),
|
|
64
66
|
__param(1, (0, common_1.Param)('token')),
|
|
@@ -68,12 +70,16 @@ __decorate([
|
|
|
68
70
|
], EmailController.prototype, "serveResetPasswordPage", null);
|
|
69
71
|
__decorate([
|
|
70
72
|
(0, swagger_1.ApiOperation)({ summary: 'Invia una e-mail per il reset della password' }),
|
|
73
|
+
(0, swagger_1.ApiBody)({ schema: { properties: { email: { type: 'string', description: "L'email dell'utente che richiede il reset" } } } }),
|
|
74
|
+
(0, swagger_1.ApiResponse)({ status: 200, description: "L'email di reset è stata inviata con successo" }),
|
|
75
|
+
(0, swagger_1.ApiResponse)({ status: 400, description: "Errore nella richiesta: protocollo o host non impostati" }),
|
|
76
|
+
(0, swagger_1.ApiResponse)({ status: 500, description: "Errore interno durante l'invio dell'email" }),
|
|
71
77
|
(0, common_1.Post)('send-reset-password-email'),
|
|
72
78
|
__param(0, (0, common_1.Req)()),
|
|
73
79
|
__param(1, (0, common_1.Body)()),
|
|
74
80
|
__param(2, (0, common_1.Res)()),
|
|
75
81
|
__metadata("design:type", Function),
|
|
76
|
-
__metadata("design:paramtypes", [
|
|
82
|
+
__metadata("design:paramtypes", [Object, Object, Object]),
|
|
77
83
|
__metadata("design:returntype", Promise)
|
|
78
84
|
], EmailController.prototype, "sendPasswordResetEmail", null);
|
|
79
85
|
exports.EmailController = EmailController = __decorate([
|
|
@@ -1,10 +1,22 @@
|
|
|
1
1
|
import { Response } from 'express';
|
|
2
2
|
import { AccessiOptions } from '../AccessiModule';
|
|
3
3
|
import { PermissionService } from '../Services/PermissionService/PermissionService';
|
|
4
|
+
import { Role } from '../Dtos/Role';
|
|
5
|
+
import { AssignRolesToUserRequest } from '../Dtos/AssignRolesToUserRequest';
|
|
6
|
+
import { AssignPermissionsToUserRequest } from '../Dtos/AssignPermissionsToUserRequest';
|
|
4
7
|
export declare class PermissionController {
|
|
5
8
|
private readonly permissionService;
|
|
6
9
|
private readonly options;
|
|
7
10
|
constructor(permissionService: PermissionService, options: AccessiOptions);
|
|
8
|
-
|
|
9
|
-
|
|
11
|
+
/**
|
|
12
|
+
* @description Endpoint per ottenere tutti i ruoli con i relativi menù.
|
|
13
|
+
* @returns Un array di ruoli con menù associati.
|
|
14
|
+
*/
|
|
15
|
+
getRoles(res: Response): Promise<void>;
|
|
16
|
+
updateRole(codiceRuolo: string, role: Role, res: Response): Promise<Response<any, Record<string, any>>>;
|
|
17
|
+
createRole(res: Response, role: Role): Promise<Response<any, Record<string, any>>>;
|
|
18
|
+
assignRolesToUser(res: Response, codiceUtente: string, assignRolesRequest: AssignRolesToUserRequest): Promise<Response<any, Record<string, any>>>;
|
|
19
|
+
assignPermissionsToUser(res: Response, codiceUtente: string, assignPermissionsRequest: AssignPermissionsToUserRequest): Promise<Response<any, Record<string, any>>>;
|
|
20
|
+
deleteRole(codiceRuolo: number, res: Response): Promise<Response<any, Record<string, any>>>;
|
|
21
|
+
getMenus(res: Response): Promise<Response<any, Record<string, any>>>;
|
|
10
22
|
}
|
|
@@ -27,27 +27,127 @@ const common_1 = require("@nestjs/common");
|
|
|
27
27
|
const swagger_1 = require("@nestjs/swagger");
|
|
28
28
|
const Utilities_1 = require("../../Utilities");
|
|
29
29
|
const PermissionService_1 = require("../Services/PermissionService/PermissionService");
|
|
30
|
+
const Role_1 = require("../Dtos/Role");
|
|
31
|
+
const AssignRolesToUserRequest_1 = require("../Dtos/AssignRolesToUserRequest");
|
|
32
|
+
const AssignPermissionsToUserRequest_1 = require("../Dtos/AssignPermissionsToUserRequest");
|
|
30
33
|
let PermissionController = PermissionController_1 = class PermissionController {
|
|
31
34
|
constructor(permissionService, options) {
|
|
32
35
|
this.permissionService = permissionService;
|
|
33
36
|
this.options = options;
|
|
34
37
|
}
|
|
35
|
-
|
|
38
|
+
/*
|
|
39
|
+
@ApiOperation({ summary: 'Resetta le abilitazioni di un utente' })
|
|
40
|
+
@Post('reset-abilitazioni')
|
|
41
|
+
async resetAbilitazioni(@Body('codiceUtente') codiceUtente: string, @Res() res: Response) {
|
|
42
|
+
try {
|
|
43
|
+
await this.permissionService.resetAbilitazioni(codiceUtente);
|
|
44
|
+
RestUtilities.sendOKMessage(res, `Le abilitazioni dell'utente ${codiceUtente} sono state resettate con successo.`);
|
|
45
|
+
} catch (error) {
|
|
46
|
+
RestUtilities.sendErrorMessage(res, error, PermissionController.name);
|
|
47
|
+
throw error;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
*/
|
|
51
|
+
/**
|
|
52
|
+
* @description Endpoint per ottenere tutti i ruoli con i relativi menù.
|
|
53
|
+
* @returns Un array di ruoli con menù associati.
|
|
54
|
+
*/
|
|
55
|
+
getRoles(res) {
|
|
36
56
|
return __awaiter(this, void 0, void 0, function* () {
|
|
37
57
|
try {
|
|
38
|
-
yield this.permissionService.
|
|
39
|
-
|
|
58
|
+
const roles = yield this.permissionService.getRolesWithMenus();
|
|
59
|
+
Utilities_1.RestUtilities.sendBaseResponse(res, roles);
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
Utilities_1.RestUtilities.sendErrorMessage(res, error, PermissionController_1.name);
|
|
63
|
+
throw error;
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
updateRole(codiceRuolo, role, res) {
|
|
68
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
69
|
+
try {
|
|
70
|
+
if (!codiceRuolo)
|
|
71
|
+
throw new Error("Il codice del ruolo è obbligatorio.");
|
|
72
|
+
if (!role.descrizioneRuolo)
|
|
73
|
+
throw new Error("La descrizione del ruolo non può essere vuota.");
|
|
74
|
+
if (!role.menu || role.menu.length === 0)
|
|
75
|
+
throw new Error("Il ruolo deve avere almeno un menù.");
|
|
76
|
+
yield this.permissionService.updateOrInsertRole(role, codiceRuolo);
|
|
77
|
+
return Utilities_1.RestUtilities.sendOKMessage(res, `Il ruolo ${codiceRuolo} è stato aggiornato con successo.`);
|
|
40
78
|
}
|
|
41
79
|
catch (error) {
|
|
42
80
|
return Utilities_1.RestUtilities.sendErrorMessage(res, error, PermissionController_1.name);
|
|
43
81
|
}
|
|
44
82
|
});
|
|
45
83
|
}
|
|
46
|
-
|
|
84
|
+
createRole(res, role) {
|
|
85
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
86
|
+
try {
|
|
87
|
+
if (!role)
|
|
88
|
+
throw new Error("Il ruolo non può essere vuoto.");
|
|
89
|
+
if (!role.descrizioneRuolo)
|
|
90
|
+
throw new Error("La descrizione del ruolo non può essere vuota.");
|
|
91
|
+
if (!role.menu || role.menu.length === 0)
|
|
92
|
+
throw new Error("Il ruolo deve avere almeno un menù.");
|
|
93
|
+
yield this.permissionService.updateOrInsertRole(role);
|
|
94
|
+
return Utilities_1.RestUtilities.sendOKMessage(res, "Il ruolo è stato creato con successo.");
|
|
95
|
+
}
|
|
96
|
+
catch (error) {
|
|
97
|
+
return Utilities_1.RestUtilities.sendErrorMessage(res, error, PermissionController_1.name);
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
assignRolesToUser(res, codiceUtente, assignRolesRequest) {
|
|
47
102
|
return __awaiter(this, void 0, void 0, function* () {
|
|
48
103
|
try {
|
|
49
|
-
|
|
50
|
-
|
|
104
|
+
if (!codiceUtente)
|
|
105
|
+
throw new Error("Il codice utente è obbligatorio.");
|
|
106
|
+
if (!assignRolesRequest.roles || assignRolesRequest.roles.length === 0) {
|
|
107
|
+
throw new Error("È necessario fornire almeno un ruolo.");
|
|
108
|
+
}
|
|
109
|
+
yield this.permissionService.assignRolesToUser(codiceUtente, assignRolesRequest.roles);
|
|
110
|
+
return Utilities_1.RestUtilities.sendOKMessage(res, `I ruoli ${assignRolesRequest.roles.join(', ')} sono stati assegnati all'utente ${codiceUtente}.`);
|
|
111
|
+
}
|
|
112
|
+
catch (error) {
|
|
113
|
+
return Utilities_1.RestUtilities.sendErrorMessage(res, error, PermissionController_1.name);
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
assignPermissionsToUser(res, codiceUtente, assignPermissionsRequest) {
|
|
118
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
119
|
+
try {
|
|
120
|
+
if (!codiceUtente)
|
|
121
|
+
throw new Error("Il codice utente è obbligatorio.");
|
|
122
|
+
if (!assignPermissionsRequest.permissions || assignPermissionsRequest.permissions.length === 0) {
|
|
123
|
+
throw new Error("È necessario fornire almeno un'abilitazione.");
|
|
124
|
+
}
|
|
125
|
+
yield this.permissionService.assignPermissionsToUser(codiceUtente, assignPermissionsRequest.permissions);
|
|
126
|
+
return Utilities_1.RestUtilities.sendOKMessage(res, `Le abilitazioni sono state assegnate all'utente ${codiceUtente}.`);
|
|
127
|
+
}
|
|
128
|
+
catch (error) {
|
|
129
|
+
return Utilities_1.RestUtilities.sendErrorMessage(res, error, PermissionController_1.name);
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
deleteRole(codiceRuolo, res) {
|
|
134
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
135
|
+
try {
|
|
136
|
+
if (!codiceRuolo)
|
|
137
|
+
throw new Error("Il codice del ruolo è obbligatorio.");
|
|
138
|
+
yield this.permissionService.deleteRole(codiceRuolo);
|
|
139
|
+
return Utilities_1.RestUtilities.sendOKMessage(res, `Il ruolo ${codiceRuolo} è stato eliminato con successo.`);
|
|
140
|
+
}
|
|
141
|
+
catch (error) {
|
|
142
|
+
return Utilities_1.RestUtilities.sendErrorMessage(res, error, PermissionController_1.name);
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
getMenus(res) {
|
|
147
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
148
|
+
try {
|
|
149
|
+
const menus = yield this.permissionService.getMenus();
|
|
150
|
+
return Utilities_1.RestUtilities.sendBaseResponse(res, menus);
|
|
51
151
|
}
|
|
52
152
|
catch (error) {
|
|
53
153
|
return Utilities_1.RestUtilities.sendErrorMessage(res, error, PermissionController_1.name);
|
|
@@ -57,22 +157,131 @@ let PermissionController = PermissionController_1 = class PermissionController {
|
|
|
57
157
|
};
|
|
58
158
|
exports.PermissionController = PermissionController;
|
|
59
159
|
__decorate([
|
|
60
|
-
(0, swagger_1.ApiOperation)({ summary: '
|
|
61
|
-
(0,
|
|
62
|
-
|
|
160
|
+
(0, swagger_1.ApiOperation)({ summary: 'Ritorna i ruoli disponibili con i relativi menù', description: 'Recupera tutti i ruoli presenti nel sistema con le relative voci di menu accessibili.' }),
|
|
161
|
+
(0, swagger_1.ApiOkResponse)({ description: 'Elenco dei ruoli con i rispettivi menù', type: [Role_1.Role] }),
|
|
162
|
+
(0, swagger_1.ApiInternalServerErrorResponse)({ description: 'Errore interno del server' }),
|
|
163
|
+
(0, swagger_1.ApiResponse)({ status: common_1.HttpStatus.OK, description: 'Lista dei ruoli con i menù restituita con successo.' }),
|
|
164
|
+
(0, swagger_1.ApiResponse)({ status: common_1.HttpStatus.INTERNAL_SERVER_ERROR, description: 'Errore interno del server durante il recupero dei ruoli.' }),
|
|
165
|
+
(0, common_1.Get)('roles'),
|
|
166
|
+
__param(0, (0, common_1.Res)()),
|
|
167
|
+
__metadata("design:type", Function),
|
|
168
|
+
__metadata("design:paramtypes", [Object]),
|
|
169
|
+
__metadata("design:returntype", Promise)
|
|
170
|
+
], PermissionController.prototype, "getRoles", null);
|
|
171
|
+
__decorate([
|
|
172
|
+
(0, swagger_1.ApiOperation)({ summary: 'Aggiorna un ruolo esistente' }),
|
|
173
|
+
(0, swagger_1.ApiParam)({
|
|
174
|
+
name: 'codiceRuolo',
|
|
175
|
+
description: "Codice identificativo del ruolo da aggiornare",
|
|
176
|
+
required: true,
|
|
177
|
+
example: "ROLE_ADMIN"
|
|
178
|
+
}),
|
|
179
|
+
(0, swagger_1.ApiBody)({
|
|
180
|
+
description: "Dati aggiornati del ruolo (escluso il codice ruolo, che è nel path)",
|
|
181
|
+
type: Role_1.Role
|
|
182
|
+
}),
|
|
183
|
+
(0, swagger_1.ApiResponse)({ status: 200, description: "Il ruolo è stato aggiornato con successo" }),
|
|
184
|
+
(0, swagger_1.ApiResponse)({ status: 400, description: "Errore di validazione nei dati inviati" }),
|
|
185
|
+
(0, swagger_1.ApiResponse)({ status: 500, description: "Errore interno del server" }),
|
|
186
|
+
(0, common_1.Put)('update-role/:codiceRuolo'),
|
|
187
|
+
__param(0, (0, common_1.Param)('codiceRuolo')),
|
|
188
|
+
__param(1, (0, common_1.Body)()),
|
|
189
|
+
__param(2, (0, common_1.Res)()),
|
|
190
|
+
__metadata("design:type", Function),
|
|
191
|
+
__metadata("design:paramtypes", [String, Role_1.Role, Object]),
|
|
192
|
+
__metadata("design:returntype", Promise)
|
|
193
|
+
], PermissionController.prototype, "updateRole", null);
|
|
194
|
+
__decorate([
|
|
195
|
+
(0, swagger_1.ApiOperation)({ summary: 'Crea un nuovo ruolo' }),
|
|
196
|
+
(0, swagger_1.ApiResponse)({ status: 201, description: 'Il ruolo è stato creato con successo' }),
|
|
197
|
+
(0, swagger_1.ApiResponse)({ status: 400, description: 'Errore di validazione nei dati inviati' }),
|
|
198
|
+
(0, swagger_1.ApiResponse)({ status: 500, description: 'Errore interno del server' }),
|
|
199
|
+
(0, swagger_1.ApiBody)({
|
|
200
|
+
description: 'Dati del nuovo ruolo',
|
|
201
|
+
required: true,
|
|
202
|
+
type: Role_1.Role
|
|
203
|
+
}),
|
|
204
|
+
(0, common_1.Post)('create-role'),
|
|
205
|
+
__param(0, (0, common_1.Res)()),
|
|
206
|
+
__param(1, (0, common_1.Body)()),
|
|
207
|
+
__metadata("design:type", Function),
|
|
208
|
+
__metadata("design:paramtypes", [Object, Role_1.Role]),
|
|
209
|
+
__metadata("design:returntype", Promise)
|
|
210
|
+
], PermissionController.prototype, "createRole", null);
|
|
211
|
+
__decorate([
|
|
212
|
+
(0, swagger_1.ApiOperation)({ summary: 'Assegna più ruoli a un utente' }),
|
|
213
|
+
(0, swagger_1.ApiParam)({
|
|
214
|
+
name: 'codiceUtente',
|
|
215
|
+
description: 'Codice identificativo dell\'utente a cui assegnare i ruoli',
|
|
216
|
+
required: true,
|
|
217
|
+
example: 'USR123'
|
|
218
|
+
}),
|
|
219
|
+
(0, swagger_1.ApiBody)({
|
|
220
|
+
type: AssignRolesToUserRequest_1.AssignRolesToUserRequest,
|
|
221
|
+
description: 'Lista dei ruoli da assegnare all\'utente'
|
|
222
|
+
}),
|
|
223
|
+
(0, swagger_1.ApiResponse)({ status: 200, description: 'Ruoli assegnati con successo all\'utente' }),
|
|
224
|
+
(0, swagger_1.ApiResponse)({ status: 400, description: 'Errore di validazione nei dati inviati' }),
|
|
225
|
+
(0, swagger_1.ApiResponse)({ status: 500, description: 'Errore interno del server' }),
|
|
226
|
+
(0, common_1.Post)('assign-roles/:codiceUtente'),
|
|
227
|
+
__param(0, (0, common_1.Res)()),
|
|
228
|
+
__param(1, (0, common_1.Param)('codiceUtente')),
|
|
229
|
+
__param(2, (0, common_1.Body)()),
|
|
230
|
+
__metadata("design:type", Function),
|
|
231
|
+
__metadata("design:paramtypes", [Object, String, AssignRolesToUserRequest_1.AssignRolesToUserRequest]),
|
|
232
|
+
__metadata("design:returntype", Promise)
|
|
233
|
+
], PermissionController.prototype, "assignRolesToUser", null);
|
|
234
|
+
__decorate([
|
|
235
|
+
(0, swagger_1.ApiOperation)({ summary: 'Assegna abilitazioni dirette a un utente' }),
|
|
236
|
+
(0, swagger_1.ApiParam)({
|
|
237
|
+
name: 'codiceUtente',
|
|
238
|
+
description: 'Codice identificativo dell\'utente a cui assegnare le abilitazioni',
|
|
239
|
+
required: true,
|
|
240
|
+
example: 'USR123'
|
|
241
|
+
}),
|
|
242
|
+
(0, swagger_1.ApiBody)({
|
|
243
|
+
type: AssignPermissionsToUserRequest_1.AssignPermissionsToUserRequest,
|
|
244
|
+
description: 'Lista delle abilitazioni da assegnare all\'utente'
|
|
245
|
+
}),
|
|
246
|
+
(0, swagger_1.ApiResponse)({ status: 200, description: 'Abilitazioni assegnate con successo all\'utente' }),
|
|
247
|
+
(0, swagger_1.ApiResponse)({ status: 400, description: 'Errore di validazione nei dati inviati' }),
|
|
248
|
+
(0, swagger_1.ApiResponse)({ status: 500, description: 'Errore interno del server' }),
|
|
249
|
+
(0, common_1.Post)('assign-permissions/:codiceUtente'),
|
|
250
|
+
__param(0, (0, common_1.Res)()),
|
|
251
|
+
__param(1, (0, common_1.Param)('codiceUtente')),
|
|
252
|
+
__param(2, (0, common_1.Body)()),
|
|
253
|
+
__metadata("design:type", Function),
|
|
254
|
+
__metadata("design:paramtypes", [Object, String, AssignPermissionsToUserRequest_1.AssignPermissionsToUserRequest]),
|
|
255
|
+
__metadata("design:returntype", Promise)
|
|
256
|
+
], PermissionController.prototype, "assignPermissionsToUser", null);
|
|
257
|
+
__decorate([
|
|
258
|
+
(0, swagger_1.ApiOperation)({ summary: 'Elimina un ruolo esistente' }),
|
|
259
|
+
(0, swagger_1.ApiParam)({
|
|
260
|
+
name: 'codiceRuolo',
|
|
261
|
+
description: "Codice identificativo del ruolo da eliminare",
|
|
262
|
+
required: true,
|
|
263
|
+
example: 382
|
|
264
|
+
}),
|
|
265
|
+
(0, swagger_1.ApiResponse)({ status: 200, description: "Ruolo eliminato con successo" }),
|
|
266
|
+
(0, swagger_1.ApiResponse)({ status: 400, description: "Errore nei parametri della richiesta" }),
|
|
267
|
+
(0, swagger_1.ApiResponse)({ status: 500, description: "Errore interno del server" }),
|
|
268
|
+
(0, common_1.Delete)('delete-role/:codiceRuolo'),
|
|
269
|
+
__param(0, (0, common_1.Param)('codiceRuolo')),
|
|
63
270
|
__param(1, (0, common_1.Res)()),
|
|
64
271
|
__metadata("design:type", Function),
|
|
65
|
-
__metadata("design:paramtypes", [
|
|
272
|
+
__metadata("design:paramtypes", [Number, Object]),
|
|
66
273
|
__metadata("design:returntype", Promise)
|
|
67
|
-
], PermissionController.prototype, "
|
|
274
|
+
], PermissionController.prototype, "deleteRole", null);
|
|
68
275
|
__decorate([
|
|
69
|
-
(0, swagger_1.ApiOperation)({ summary: '
|
|
70
|
-
(0,
|
|
276
|
+
(0, swagger_1.ApiOperation)({ summary: 'Recupera tutti i menù disponibili' }),
|
|
277
|
+
(0, swagger_1.ApiResponse)({ status: 200, description: "Lista dei menù recuperata con successo" }),
|
|
278
|
+
(0, swagger_1.ApiResponse)({ status: 500, description: "Errore interno del server" }),
|
|
279
|
+
(0, common_1.Get)('menus'),
|
|
71
280
|
__param(0, (0, common_1.Res)()),
|
|
72
281
|
__metadata("design:type", Function),
|
|
73
282
|
__metadata("design:paramtypes", [Object]),
|
|
74
283
|
__metadata("design:returntype", Promise)
|
|
75
|
-
], PermissionController.prototype, "
|
|
284
|
+
], PermissionController.prototype, "getMenus", null);
|
|
76
285
|
exports.PermissionController = PermissionController = PermissionController_1 = __decorate([
|
|
77
286
|
(0, swagger_1.ApiTags)('Permission'),
|
|
78
287
|
(0, common_1.Controller)('accessi/permission'),
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Response, Request } from 'express';
|
|
2
|
+
import { AccessiOptions } from '../AccessiModule';
|
|
3
|
+
import { UserService } from '../Services/UserService/UserService';
|
|
4
|
+
import { EmailService } from '../Services/EmailService/EmailService';
|
|
5
|
+
import { User } from '../Dtos';
|
|
6
|
+
export declare class UserController {
|
|
7
|
+
private readonly userService;
|
|
8
|
+
private readonly emailService;
|
|
9
|
+
private readonly options;
|
|
10
|
+
constructor(userService: UserService, emailService: EmailService, options: AccessiOptions);
|
|
11
|
+
serveResetPasswordPage(res: Response, token: string): Promise<void>;
|
|
12
|
+
getUsers(res: Response): Promise<Response<any, Record<string, any>>>;
|
|
13
|
+
deleteUser(codiceUtente: string, res: Response): Promise<Response<any, Record<string, any>>>;
|
|
14
|
+
register(request: Request, registrationData: User, res: Response): Promise<Response<any, Record<string, any>>>;
|
|
15
|
+
updateUtente(codiceUtente: string, user: User, res: Response): Promise<Response<any, Record<string, any>>>;
|
|
16
|
+
setGdpr(codiceUtente: string, res: Response): Promise<Response<any, Record<string, any>>>;
|
|
17
|
+
}
|