emilsoftware-utilities 1.3.97 → 1.3.98
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 +2 -2
- package/dist/accessi-module/Controllers/AccessiController.js +3 -2
- package/dist/accessi-module/Controllers/AuthController.js +15 -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 +12 -2
- package/dist/accessi-module/Controllers/PermissionController.js +169 -16
- package/dist/accessi-module/Controllers/UserController.d.ts +17 -0
- package/dist/accessi-module/Controllers/UserController.js +185 -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/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 +6 -0
- package/dist/accessi-module/Dtos/MenuItem.js +33 -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/RoleWithMenus.d.ts +6 -0
- package/dist/accessi-module/Dtos/RoleWithMenus.js +32 -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 +16 -0
- package/dist/accessi-module/Dtos/User.js +111 -0
- package/dist/accessi-module/Dtos/index.d.ts +14 -0
- package/dist/accessi-module/Dtos/index.js +30 -0
- package/dist/accessi-module/Services/AuthService/AuthService.d.ts +6 -5
- package/dist/accessi-module/Services/AuthService/AuthService.js +23 -19
- 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 +9 -5
- package/dist/accessi-module/Services/PermissionService/PermissionService.js +88 -5
- package/dist/accessi-module/Services/UserService/UserService.d.ts +8 -7
- package/dist/accessi-module/Services/UserService/UserService.js +4 -4
- package/dist/accessi-module/index.d.ts +1 -3
- package/dist/accessi-module/index.js +32 -15
- package/dist/accessi-module/models/QueryResults/MenuAbilitazioniResult.d.ts +1 -1
- package/dist/accessi-module/swagger/SwaggerConfig.js +3 -2
- package/dist/index.d.ts +2 -1
- package/dist/index.js +4 -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 → 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;
|
|
@@ -21,7 +21,7 @@ export declare class AccessiController {
|
|
|
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>>>;
|
|
@@ -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;
|
|
@@ -291,7 +292,7 @@ __decorate([
|
|
|
291
292
|
__param(1, (0, common_1.Body)()),
|
|
292
293
|
__param(2, (0, common_1.Res)()),
|
|
293
294
|
__metadata("design:type", Function),
|
|
294
|
-
__metadata("design:paramtypes", [Request,
|
|
295
|
+
__metadata("design:paramtypes", [Request, Dtos_1.User, Object]),
|
|
295
296
|
__metadata("design:returntype", Promise)
|
|
296
297
|
], AccessiController.prototype, "register", null);
|
|
297
298
|
__decorate([
|
|
@@ -350,7 +351,7 @@ __decorate([
|
|
|
350
351
|
], AccessiController.prototype, "setGdpr", null);
|
|
351
352
|
exports.AccessiController = AccessiController = AccessiController_1 = __decorate([
|
|
352
353
|
(0, Utilities_1.Deprecated)("AccessiController è deprecato. Usa i controller specifici per ogni area."),
|
|
353
|
-
(0, swagger_1.ApiTags)('
|
|
354
|
+
(0, swagger_1.ApiTags)('AccessiDEPRECATED'),
|
|
354
355
|
(0, common_1.Controller)('accessi'),
|
|
355
356
|
__param(4, (0, common_1.Inject)('ACCESSI_OPTIONS')),
|
|
356
357
|
__metadata("design:paramtypes", [UserService_1.UserService,
|
|
@@ -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,14 @@ __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)({ schema: {
|
|
144
|
+
properties: {
|
|
145
|
+
username: { type: 'string', description: 'Username dell\'utente' },
|
|
146
|
+
password: { type: 'string', description: 'Password dell\'utente' }
|
|
147
|
+
}
|
|
148
|
+
} }),
|
|
149
|
+
(0, swagger_1.ApiResponse)({ status: 200, description: 'Login effettuato con successo' }),
|
|
150
|
+
(0, swagger_1.ApiResponse)({ status: 401, description: 'Credenziali non valide' }),
|
|
136
151
|
(0, common_1.Post)('login'),
|
|
137
152
|
__param(0, (0, common_1.Body)()),
|
|
138
153
|
__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,20 @@
|
|
|
1
1
|
import { Response } from 'express';
|
|
2
2
|
import { AccessiOptions } from '../AccessiModule';
|
|
3
3
|
import { PermissionService } from '../Services/PermissionService/PermissionService';
|
|
4
|
+
import { RoleWithMenus } from '../Dtos/RoleWithMenus';
|
|
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(res: Response, role: RoleWithMenus): Promise<Response<any, Record<string, any>>>;
|
|
17
|
+
createRole(res: Response, role: RoleWithMenus): 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>>>;
|
|
10
20
|
}
|
|
@@ -27,27 +27,105 @@ 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 RoleWithMenus_1 = require("../Dtos/RoleWithMenus");
|
|
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) {
|
|
56
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
57
|
+
try {
|
|
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(res, role) {
|
|
36
68
|
return __awaiter(this, void 0, void 0, function* () {
|
|
37
69
|
try {
|
|
38
|
-
|
|
39
|
-
|
|
70
|
+
if (!role)
|
|
71
|
+
throw new Error("Il ruolo non può essere vuoto.");
|
|
72
|
+
if (!role.codiceRuolo)
|
|
73
|
+
throw new Error("Il codice del ruolo non può essere vuoto.");
|
|
74
|
+
if (!role.descrizioneRuolo)
|
|
75
|
+
throw new Error("La descrizione del ruolo non può essere vuota.");
|
|
76
|
+
if (!role.menu || role.menu.length === 0)
|
|
77
|
+
throw new Error("Il ruolo deve avere almeno un menù.");
|
|
78
|
+
yield this.permissionService.updateOrInsertRole(role);
|
|
79
|
+
return Utilities_1.RestUtilities.sendOKMessage(res, "Il ruolo è stato aggiornato con successo.");
|
|
40
80
|
}
|
|
41
81
|
catch (error) {
|
|
42
82
|
return Utilities_1.RestUtilities.sendErrorMessage(res, error, PermissionController_1.name);
|
|
43
83
|
}
|
|
44
84
|
});
|
|
45
85
|
}
|
|
46
|
-
|
|
86
|
+
createRole(res, role) {
|
|
87
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
88
|
+
try {
|
|
89
|
+
if (!role)
|
|
90
|
+
throw new Error("Il ruolo non può essere vuoto.");
|
|
91
|
+
if (!role.descrizioneRuolo)
|
|
92
|
+
throw new Error("La descrizione del ruolo non può essere vuota.");
|
|
93
|
+
if (!role.menu || role.menu.length === 0)
|
|
94
|
+
throw new Error("Il ruolo deve avere almeno un menù.");
|
|
95
|
+
yield this.permissionService.updateOrInsertRole(role);
|
|
96
|
+
return Utilities_1.RestUtilities.sendOKMessage(res, "Il ruolo è stato creato con successo.");
|
|
97
|
+
}
|
|
98
|
+
catch (error) {
|
|
99
|
+
return Utilities_1.RestUtilities.sendErrorMessage(res, error, PermissionController_1.name);
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
assignRolesToUser(res, codiceUtente, assignRolesRequest) {
|
|
104
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
105
|
+
try {
|
|
106
|
+
if (!codiceUtente)
|
|
107
|
+
throw new Error("Il codice utente è obbligatorio.");
|
|
108
|
+
if (!assignRolesRequest.roles || assignRolesRequest.roles.length === 0) {
|
|
109
|
+
throw new Error("È necessario fornire almeno un ruolo.");
|
|
110
|
+
}
|
|
111
|
+
yield this.permissionService.assignRolesToUser(codiceUtente, assignRolesRequest.roles);
|
|
112
|
+
return Utilities_1.RestUtilities.sendOKMessage(res, `I ruoli ${assignRolesRequest.roles.join(', ')} sono stati assegnati all'utente ${codiceUtente}.`);
|
|
113
|
+
}
|
|
114
|
+
catch (error) {
|
|
115
|
+
return Utilities_1.RestUtilities.sendErrorMessage(res, error, PermissionController_1.name);
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
assignPermissionsToUser(res, codiceUtente, assignPermissionsRequest) {
|
|
47
120
|
return __awaiter(this, void 0, void 0, function* () {
|
|
48
121
|
try {
|
|
49
|
-
|
|
50
|
-
|
|
122
|
+
if (!codiceUtente)
|
|
123
|
+
throw new Error("Il codice utente è obbligatorio.");
|
|
124
|
+
if (!assignPermissionsRequest.permissions || assignPermissionsRequest.permissions.length === 0) {
|
|
125
|
+
throw new Error("È necessario fornire almeno un'abilitazione.");
|
|
126
|
+
}
|
|
127
|
+
yield this.permissionService.assignPermissionsToUser(codiceUtente, assignPermissionsRequest.permissions);
|
|
128
|
+
return Utilities_1.RestUtilities.sendOKMessage(res, `Le abilitazioni sono state assegnate all'utente ${codiceUtente}.`);
|
|
51
129
|
}
|
|
52
130
|
catch (error) {
|
|
53
131
|
return Utilities_1.RestUtilities.sendErrorMessage(res, error, PermissionController_1.name);
|
|
@@ -57,22 +135,97 @@ let PermissionController = PermissionController_1 = class PermissionController {
|
|
|
57
135
|
};
|
|
58
136
|
exports.PermissionController = PermissionController;
|
|
59
137
|
__decorate([
|
|
60
|
-
(0, swagger_1.ApiOperation)({ summary: '
|
|
61
|
-
(0,
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
__metadata("design:paramtypes", [String, Object]),
|
|
66
|
-
__metadata("design:returntype", Promise)
|
|
67
|
-
], PermissionController.prototype, "resetAbilitazioni", null);
|
|
68
|
-
__decorate([
|
|
69
|
-
(0, swagger_1.ApiOperation)({ summary: 'Resetta le abilitazioni di un utente' }),
|
|
138
|
+
(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.' }),
|
|
139
|
+
(0, swagger_1.ApiOkResponse)({ description: 'Elenco dei ruoli con i rispettivi menù', type: [RoleWithMenus_1.RoleWithMenus] }),
|
|
140
|
+
(0, swagger_1.ApiInternalServerErrorResponse)({ description: 'Errore interno del server' }),
|
|
141
|
+
(0, swagger_1.ApiResponse)({ status: common_1.HttpStatus.OK, description: 'Lista dei ruoli con i menù restituita con successo.' }),
|
|
142
|
+
(0, swagger_1.ApiResponse)({ status: common_1.HttpStatus.INTERNAL_SERVER_ERROR, description: 'Errore interno del server durante il recupero dei ruoli.' }),
|
|
70
143
|
(0, common_1.Get)('roles'),
|
|
71
144
|
__param(0, (0, common_1.Res)()),
|
|
72
145
|
__metadata("design:type", Function),
|
|
73
146
|
__metadata("design:paramtypes", [Object]),
|
|
74
147
|
__metadata("design:returntype", Promise)
|
|
75
148
|
], PermissionController.prototype, "getRoles", null);
|
|
149
|
+
__decorate([
|
|
150
|
+
(0, swagger_1.ApiOperation)({ summary: 'Aggiorna un ruolo esistente' }),
|
|
151
|
+
(0, swagger_1.ApiResponse)({ status: 200, description: 'Il ruolo è stato aggiornato con successo' }),
|
|
152
|
+
(0, swagger_1.ApiResponse)({ status: 400, description: 'Errore di validazione nei dati inviati' }),
|
|
153
|
+
(0, swagger_1.ApiResponse)({ status: 500, description: 'Errore interno del server' }),
|
|
154
|
+
(0, swagger_1.ApiBody)({
|
|
155
|
+
description: 'Dati del ruolo da aggiornare',
|
|
156
|
+
required: true,
|
|
157
|
+
type: RoleWithMenus_1.RoleWithMenus
|
|
158
|
+
}),
|
|
159
|
+
(0, common_1.Put)('update-role'),
|
|
160
|
+
__param(0, (0, common_1.Res)()),
|
|
161
|
+
__param(1, (0, common_1.Body)()),
|
|
162
|
+
__metadata("design:type", Function),
|
|
163
|
+
__metadata("design:paramtypes", [Object, RoleWithMenus_1.RoleWithMenus]),
|
|
164
|
+
__metadata("design:returntype", Promise)
|
|
165
|
+
], PermissionController.prototype, "updateRole", null);
|
|
166
|
+
__decorate([
|
|
167
|
+
(0, swagger_1.ApiOperation)({ summary: 'Crea un nuovo ruolo' }),
|
|
168
|
+
(0, swagger_1.ApiResponse)({ status: 201, description: 'Il ruolo è stato creato con successo' }),
|
|
169
|
+
(0, swagger_1.ApiResponse)({ status: 400, description: 'Errore di validazione nei dati inviati' }),
|
|
170
|
+
(0, swagger_1.ApiResponse)({ status: 500, description: 'Errore interno del server' }),
|
|
171
|
+
(0, swagger_1.ApiBody)({
|
|
172
|
+
description: 'Dati del nuovo ruolo',
|
|
173
|
+
required: true,
|
|
174
|
+
type: RoleWithMenus_1.RoleWithMenus
|
|
175
|
+
}),
|
|
176
|
+
(0, common_1.Post)('create-role'),
|
|
177
|
+
__param(0, (0, common_1.Res)()),
|
|
178
|
+
__param(1, (0, common_1.Body)()),
|
|
179
|
+
__metadata("design:type", Function),
|
|
180
|
+
__metadata("design:paramtypes", [Object, RoleWithMenus_1.RoleWithMenus]),
|
|
181
|
+
__metadata("design:returntype", Promise)
|
|
182
|
+
], PermissionController.prototype, "createRole", null);
|
|
183
|
+
__decorate([
|
|
184
|
+
(0, swagger_1.ApiOperation)({ summary: 'Assegna più ruoli a un utente' }),
|
|
185
|
+
(0, swagger_1.ApiParam)({
|
|
186
|
+
name: 'codiceUtente',
|
|
187
|
+
description: 'Codice identificativo dell\'utente a cui assegnare i ruoli',
|
|
188
|
+
required: true,
|
|
189
|
+
example: 'USR123'
|
|
190
|
+
}),
|
|
191
|
+
(0, swagger_1.ApiBody)({
|
|
192
|
+
type: AssignRolesToUserRequest_1.AssignRolesToUserRequest,
|
|
193
|
+
description: 'Lista dei ruoli da assegnare all\'utente'
|
|
194
|
+
}),
|
|
195
|
+
(0, swagger_1.ApiResponse)({ status: 200, description: 'Ruoli assegnati con successo all\'utente' }),
|
|
196
|
+
(0, swagger_1.ApiResponse)({ status: 400, description: 'Errore di validazione nei dati inviati' }),
|
|
197
|
+
(0, swagger_1.ApiResponse)({ status: 500, description: 'Errore interno del server' }),
|
|
198
|
+
(0, common_1.Post)('assign-roles/:codiceUtente'),
|
|
199
|
+
__param(0, (0, common_1.Res)()),
|
|
200
|
+
__param(1, (0, common_1.Param)('codiceUtente')),
|
|
201
|
+
__param(2, (0, common_1.Body)()),
|
|
202
|
+
__metadata("design:type", Function),
|
|
203
|
+
__metadata("design:paramtypes", [Object, String, AssignRolesToUserRequest_1.AssignRolesToUserRequest]),
|
|
204
|
+
__metadata("design:returntype", Promise)
|
|
205
|
+
], PermissionController.prototype, "assignRolesToUser", null);
|
|
206
|
+
__decorate([
|
|
207
|
+
(0, swagger_1.ApiOperation)({ summary: 'Assegna abilitazioni dirette a un utente' }),
|
|
208
|
+
(0, swagger_1.ApiParam)({
|
|
209
|
+
name: 'codiceUtente',
|
|
210
|
+
description: 'Codice identificativo dell\'utente a cui assegnare le abilitazioni',
|
|
211
|
+
required: true,
|
|
212
|
+
example: 'USR123'
|
|
213
|
+
}),
|
|
214
|
+
(0, swagger_1.ApiBody)({
|
|
215
|
+
type: AssignPermissionsToUserRequest_1.AssignPermissionsToUserRequest,
|
|
216
|
+
description: 'Lista delle abilitazioni da assegnare all\'utente'
|
|
217
|
+
}),
|
|
218
|
+
(0, swagger_1.ApiResponse)({ status: 200, description: 'Abilitazioni assegnate con successo all\'utente' }),
|
|
219
|
+
(0, swagger_1.ApiResponse)({ status: 400, description: 'Errore di validazione nei dati inviati' }),
|
|
220
|
+
(0, swagger_1.ApiResponse)({ status: 500, description: 'Errore interno del server' }),
|
|
221
|
+
(0, common_1.Post)('assign-permissions/:codiceUtente'),
|
|
222
|
+
__param(0, (0, common_1.Res)()),
|
|
223
|
+
__param(1, (0, common_1.Param)('codiceUtente')),
|
|
224
|
+
__param(2, (0, common_1.Body)()),
|
|
225
|
+
__metadata("design:type", Function),
|
|
226
|
+
__metadata("design:paramtypes", [Object, String, AssignPermissionsToUserRequest_1.AssignPermissionsToUserRequest]),
|
|
227
|
+
__metadata("design:returntype", Promise)
|
|
228
|
+
], PermissionController.prototype, "assignPermissionsToUser", null);
|
|
76
229
|
exports.PermissionController = PermissionController = PermissionController_1 = __decorate([
|
|
77
230
|
(0, swagger_1.ApiTags)('Permission'),
|
|
78
231
|
(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(user: User, res: Response): Promise<Response<any, Record<string, any>>>;
|
|
16
|
+
setGdpr(codiceUtente: string, res: Response): Promise<Response<any, Record<string, any>>>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
15
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
16
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
17
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
18
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
19
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
20
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
var UserController_1;
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.UserController = void 0;
|
|
26
|
+
const common_1 = require("@nestjs/common");
|
|
27
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
28
|
+
const Utilities_1 = require("../../Utilities");
|
|
29
|
+
const UserService_1 = require("../Services/UserService/UserService");
|
|
30
|
+
const EmailService_1 = require("../Services/EmailService/EmailService");
|
|
31
|
+
const path_1 = require("path");
|
|
32
|
+
const Dtos_1 = require("../Dtos");
|
|
33
|
+
let UserController = UserController_1 = class UserController {
|
|
34
|
+
constructor(userService, emailService, options) {
|
|
35
|
+
this.userService = userService;
|
|
36
|
+
this.emailService = emailService;
|
|
37
|
+
this.options = options;
|
|
38
|
+
}
|
|
39
|
+
serveResetPasswordPage(res, token) {
|
|
40
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
+
return res.sendFile((0, path_1.join)(__dirname, '..', 'Views', 'reset-password.html'));
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
getUsers(res) {
|
|
45
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
46
|
+
try {
|
|
47
|
+
const users = yield this.userService.getUsers();
|
|
48
|
+
return Utilities_1.RestUtilities.sendBaseResponse(res, users);
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
return Utilities_1.RestUtilities.sendInvalidCredentials(res);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
deleteUser(codiceUtente, res) {
|
|
56
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
57
|
+
try {
|
|
58
|
+
if (!codiceUtente)
|
|
59
|
+
throw new Error('Il campo "Codice Utente" è obbligatorio.');
|
|
60
|
+
yield this.userService.deleteUser(codiceUtente);
|
|
61
|
+
return Utilities_1.RestUtilities.sendOKMessage(res, "L'utente è stato eliminato con successo.");
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
return Utilities_1.RestUtilities.sendErrorMessage(res, error);
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
register(request, registrationData, res) {
|
|
69
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
70
|
+
try {
|
|
71
|
+
let protocol = request["protocol"];
|
|
72
|
+
let host = request.headers["host"];
|
|
73
|
+
if (!protocol || !host) {
|
|
74
|
+
throw new Error("Impossibile procedere: protocollo e host non impostati negli header della richiesta.");
|
|
75
|
+
}
|
|
76
|
+
yield this.userService.register(registrationData);
|
|
77
|
+
let confirmationEmailPrefix = `${protocol}://${host}`;
|
|
78
|
+
yield this.emailService.sendPasswordResetEmail(registrationData.username, confirmationEmailPrefix);
|
|
79
|
+
return Utilities_1.RestUtilities.sendOKMessage(res, "L'utente è stato registrato con successo, email di conferma inoltrata al destinatario.");
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
return Utilities_1.RestUtilities.sendErrorMessage(res, error, UserController_1.name);
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
updateUtente(user, res) {
|
|
87
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
88
|
+
try {
|
|
89
|
+
yield this.userService.updateUser(user);
|
|
90
|
+
return Utilities_1.RestUtilities.sendOKMessage(res, `L'utente ${user.codiceUtente} è stato aggiornato con successo.`);
|
|
91
|
+
}
|
|
92
|
+
catch (error) {
|
|
93
|
+
return Utilities_1.RestUtilities.sendErrorMessage(res, error, UserController_1.name);
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
setGdpr(codiceUtente, res) {
|
|
98
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
99
|
+
try {
|
|
100
|
+
yield this.userService.setGdpr(codiceUtente);
|
|
101
|
+
return Utilities_1.RestUtilities.sendOKMessage(res, `L'utente ${codiceUtente} ha accettato il GDPR.`);
|
|
102
|
+
}
|
|
103
|
+
catch (error) {
|
|
104
|
+
return Utilities_1.RestUtilities.sendErrorMessage(res, error, UserController_1.name);
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
exports.UserController = UserController;
|
|
110
|
+
__decorate([
|
|
111
|
+
(0, swagger_1.ApiOperation)({ summary: 'Servire la pagina di reset password' }),
|
|
112
|
+
(0, swagger_1.ApiParam)({ name: 'token', description: 'Token per il reset della password', required: true }),
|
|
113
|
+
(0, common_1.Get)('reset-password/:token'),
|
|
114
|
+
__param(0, (0, common_1.Res)()),
|
|
115
|
+
__param(1, (0, common_1.Param)('token')),
|
|
116
|
+
__metadata("design:type", Function),
|
|
117
|
+
__metadata("design:paramtypes", [Object, String]),
|
|
118
|
+
__metadata("design:returntype", Promise)
|
|
119
|
+
], UserController.prototype, "serveResetPasswordPage", null);
|
|
120
|
+
__decorate([
|
|
121
|
+
(0, swagger_1.ApiOperation)({ summary: 'Recupera la lista degli utenti' }),
|
|
122
|
+
(0, swagger_1.ApiResponse)({ status: 200, description: 'Lista utenti recuperata con successo' }),
|
|
123
|
+
(0, swagger_1.ApiResponse)({ status: 401, description: 'Credenziali non valide' }),
|
|
124
|
+
(0, common_1.Get)('get-users'),
|
|
125
|
+
__param(0, (0, common_1.Res)()),
|
|
126
|
+
__metadata("design:type", Function),
|
|
127
|
+
__metadata("design:paramtypes", [Object]),
|
|
128
|
+
__metadata("design:returntype", Promise)
|
|
129
|
+
], UserController.prototype, "getUsers", null);
|
|
130
|
+
__decorate([
|
|
131
|
+
(0, swagger_1.ApiOperation)({ summary: 'Elimina un utente' }),
|
|
132
|
+
(0, swagger_1.ApiBody)({ schema: { properties: { codiceUtente: { type: 'string', description: 'Codice identificativo dell\'utente' } } } }),
|
|
133
|
+
(0, swagger_1.ApiResponse)({ status: 200, description: 'Utente eliminato con successo' }),
|
|
134
|
+
(0, swagger_1.ApiResponse)({ status: 400, description: 'Errore nei parametri della richiesta' }),
|
|
135
|
+
(0, common_1.Delete)('delete-user'),
|
|
136
|
+
__param(0, (0, common_1.Body)('codiceUtente')),
|
|
137
|
+
__param(1, (0, common_1.Res)()),
|
|
138
|
+
__metadata("design:type", Function),
|
|
139
|
+
__metadata("design:paramtypes", [String, Object]),
|
|
140
|
+
__metadata("design:returntype", Promise)
|
|
141
|
+
], UserController.prototype, "deleteUser", null);
|
|
142
|
+
__decorate([
|
|
143
|
+
(0, swagger_1.ApiOperation)({ summary: 'Registra un nuovo utente' }),
|
|
144
|
+
(0, swagger_1.ApiBody)({ type: Dtos_1.User, description: 'Dati dell\'utente da registrare' }),
|
|
145
|
+
(0, swagger_1.ApiResponse)({ status: 201, description: 'Utente registrato con successo' }),
|
|
146
|
+
(0, swagger_1.ApiResponse)({ status: 400, description: 'Errore nella registrazione' }),
|
|
147
|
+
(0, common_1.Post)('register'),
|
|
148
|
+
__param(0, (0, common_1.Req)()),
|
|
149
|
+
__param(1, (0, common_1.Body)()),
|
|
150
|
+
__param(2, (0, common_1.Res)()),
|
|
151
|
+
__metadata("design:type", Function),
|
|
152
|
+
__metadata("design:paramtypes", [Object, Dtos_1.User, Object]),
|
|
153
|
+
__metadata("design:returntype", Promise)
|
|
154
|
+
], UserController.prototype, "register", null);
|
|
155
|
+
__decorate([
|
|
156
|
+
(0, swagger_1.ApiOperation)({ summary: 'Aggiorna un utente esistente' }),
|
|
157
|
+
(0, swagger_1.ApiBody)({ type: Dtos_1.User, description: 'Dati aggiornati dell\'utente' }),
|
|
158
|
+
(0, swagger_1.ApiResponse)({ status: 200, description: 'Utente aggiornato con successo' }),
|
|
159
|
+
(0, swagger_1.ApiResponse)({ status: 400, description: 'Errore nellaggiornamento' }),
|
|
160
|
+
(0, common_1.Put)('update-utente'),
|
|
161
|
+
__param(0, (0, common_1.Body)()),
|
|
162
|
+
__param(1, (0, common_1.Res)()),
|
|
163
|
+
__metadata("design:type", Function),
|
|
164
|
+
__metadata("design:paramtypes", [Dtos_1.User, Object]),
|
|
165
|
+
__metadata("design:returntype", Promise)
|
|
166
|
+
], UserController.prototype, "updateUtente", null);
|
|
167
|
+
__decorate([
|
|
168
|
+
(0, swagger_1.ApiOperation)({ summary: 'Imposta il consenso GDPR' }),
|
|
169
|
+
(0, swagger_1.ApiBody)({ schema: { properties: { codiceUtente: { type: 'string', description: 'Codice identificativo dell\'utente' } } } }),
|
|
170
|
+
(0, swagger_1.ApiResponse)({ status: 200, description: 'Consenso GDPR impostato con successo' }),
|
|
171
|
+
(0, swagger_1.ApiResponse)({ status: 400, description: 'Errore nella richiesta' }),
|
|
172
|
+
(0, common_1.Patch)('set-gdpr'),
|
|
173
|
+
__param(0, (0, common_1.Body)('codiceUtente')),
|
|
174
|
+
__param(1, (0, common_1.Res)()),
|
|
175
|
+
__metadata("design:type", Function),
|
|
176
|
+
__metadata("design:paramtypes", [String, Object]),
|
|
177
|
+
__metadata("design:returntype", Promise)
|
|
178
|
+
], UserController.prototype, "setGdpr", null);
|
|
179
|
+
exports.UserController = UserController = UserController_1 = __decorate([
|
|
180
|
+
(0, swagger_1.ApiTags)('User'),
|
|
181
|
+
(0, common_1.Controller)('accessi/user'),
|
|
182
|
+
__param(2, (0, common_1.Inject)('ACCESSI_OPTIONS')),
|
|
183
|
+
__metadata("design:paramtypes", [UserService_1.UserService,
|
|
184
|
+
EmailService_1.EmailService, Object])
|
|
185
|
+
], UserController);
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.Abilitazione = void 0;
|
|
13
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
14
|
+
const TipoAbilitazione_1 = require("./TipoAbilitazione");
|
|
15
|
+
const class_validator_1 = require("class-validator");
|
|
16
|
+
class Abilitazione {
|
|
17
|
+
}
|
|
18
|
+
exports.Abilitazione = Abilitazione;
|
|
19
|
+
__decorate([
|
|
20
|
+
(0, swagger_1.ApiProperty)({
|
|
21
|
+
description: 'Codice univoco dell\'utente',
|
|
22
|
+
example: 'USR12345'
|
|
23
|
+
}),
|
|
24
|
+
(0, class_validator_1.IsString)(),
|
|
25
|
+
(0, class_validator_1.IsNotEmpty)({ message: "Il codice utente è obbligatorio." }),
|
|
26
|
+
(0, class_validator_1.Length)(5, 20, { message: "Il codice utente deve essere tra 5 e 20 caratteri." }),
|
|
27
|
+
__metadata("design:type", String)
|
|
28
|
+
], Abilitazione.prototype, "codiceUtente", void 0);
|
|
29
|
+
__decorate([
|
|
30
|
+
(0, swagger_1.ApiProperty)({
|
|
31
|
+
description: 'Codice univoco del menu',
|
|
32
|
+
example: 'MENU_001'
|
|
33
|
+
}),
|
|
34
|
+
(0, class_validator_1.IsString)(),
|
|
35
|
+
(0, class_validator_1.IsNotEmpty)({ message: "Il codice menu è obbligatorio." }),
|
|
36
|
+
(0, class_validator_1.Length)(3, 20, { message: "Il codice menu deve essere tra 3 e 20 caratteri." }),
|
|
37
|
+
__metadata("design:type", String)
|
|
38
|
+
], Abilitazione.prototype, "codiceMenu", void 0);
|
|
39
|
+
__decorate([
|
|
40
|
+
(0, swagger_1.ApiProperty)({
|
|
41
|
+
description: 'Tipo di abilitazione',
|
|
42
|
+
enum: TipoAbilitazione_1.TipoAbilitazione,
|
|
43
|
+
example: TipoAbilitazione_1.TipoAbilitazione.LETTURA
|
|
44
|
+
}),
|
|
45
|
+
(0, class_validator_1.IsEnum)(TipoAbilitazione_1.TipoAbilitazione, { message: "Il tipo di abilitazione non è valido." }),
|
|
46
|
+
__metadata("design:type", Number)
|
|
47
|
+
], Abilitazione.prototype, "tipoAbilitazione", void 0);
|