emilsoftware-utilities 2.0.0-dev.41 → 2.0.0-dev.43
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.d.ts +1 -0
- package/dist/accessi-module/AccessiModule.js +2 -0
- package/dist/accessi-module/AccessiModule.js.map +1 -1
- package/dist/accessi-module/Console/console.js +407 -30
- package/dist/accessi-module/Console/console.js.map +1 -1
- package/dist/accessi-module/Console/generated/accessiApi.d.ts +41 -1
- package/dist/accessi-module/Console/generated/accessiApi.js +34 -2
- package/dist/accessi-module/Console/generated/accessiApi.js.map +1 -1
- package/dist/accessi-module/Console/generated/model/confirmResetPasswordRequest.d.ts +1 -1
- package/dist/accessi-module/Console/generated/model/confirmResetPasswordRequest.js.map +1 -1
- package/dist/accessi-module/Console/generated/model/consoleEntryExchangeRequest.d.ts +10 -0
- package/dist/accessi-module/Console/generated/model/consoleEntryExchangeRequest.js +9 -0
- package/dist/accessi-module/Console/generated/model/consoleEntryExchangeRequest.js.map +1 -0
- package/dist/accessi-module/Console/generated/model/consoleEntrySessionResponse.d.ts +14 -0
- package/dist/accessi-module/Console/generated/model/consoleEntrySessionResponse.js +3 -0
- package/dist/accessi-module/Console/generated/model/consoleEntrySessionResponse.js.map +1 -0
- package/dist/accessi-module/Console/generated/model/consoleEntrySessionResult.d.ts +10 -0
- package/dist/accessi-module/Console/generated/model/consoleEntrySessionResult.js +3 -0
- package/dist/accessi-module/Console/generated/model/consoleEntrySessionResult.js.map +1 -0
- package/dist/accessi-module/Console/generated/model/consoleEntryTicketResponse.d.ts +14 -0
- package/dist/accessi-module/Console/generated/model/consoleEntryTicketResponse.js +3 -0
- package/dist/accessi-module/Console/generated/model/consoleEntryTicketResponse.js.map +1 -0
- package/dist/accessi-module/Console/generated/model/consoleEntryTicketResult.d.ts +12 -0
- package/dist/accessi-module/Console/generated/model/consoleEntryTicketResult.js +9 -0
- package/dist/accessi-module/Console/generated/model/consoleEntryTicketResult.js.map +1 -0
- package/dist/accessi-module/Console/generated/model/consoleEntryTokenResult.d.ts +12 -0
- package/dist/accessi-module/Console/generated/model/consoleEntryTokenResult.js +9 -0
- package/dist/accessi-module/Console/generated/model/consoleEntryTokenResult.js.map +1 -0
- package/dist/accessi-module/Console/generated/model/index.d.ts +7 -0
- package/dist/accessi-module/Console/generated/model/index.js +7 -0
- package/dist/accessi-module/Console/generated/model/index.js.map +1 -1
- package/dist/accessi-module/Console/generated/model/setUserPasswordRequest.d.ts +14 -0
- package/dist/accessi-module/Console/generated/model/setUserPasswordRequest.js +9 -0
- package/dist/accessi-module/Console/generated/model/setUserPasswordRequest.js.map +1 -0
- package/dist/accessi-module/Console/help.js +116 -0
- package/dist/accessi-module/Console/help.js.map +1 -1
- package/dist/accessi-module/Console/wiki.js +14 -3
- package/dist/accessi-module/Console/wiki.js.map +1 -1
- package/dist/accessi-module/Controllers/ConsoleEntryController.d.ts +14 -0
- package/dist/accessi-module/Controllers/ConsoleEntryController.js +128 -0
- package/dist/accessi-module/Controllers/ConsoleEntryController.js.map +1 -0
- package/dist/accessi-module/Controllers/FiltriController.d.ts +8 -1
- package/dist/accessi-module/Controllers/FiltriController.js +21 -2
- package/dist/accessi-module/Controllers/FiltriController.js.map +1 -1
- package/dist/accessi-module/Controllers/PermissionController.d.ts +8 -1
- package/dist/accessi-module/Controllers/PermissionController.js +24 -4
- package/dist/accessi-module/Controllers/PermissionController.js.map +1 -1
- package/dist/accessi-module/Controllers/UserController.d.ts +12 -1
- package/dist/accessi-module/Controllers/UserController.js +175 -9
- package/dist/accessi-module/Controllers/UserController.js.map +1 -1
- package/dist/accessi-module/Dtos/ConfirmResetPasswordRequest.js +1 -1
- package/dist/accessi-module/Dtos/ConfirmResetPasswordRequest.js.map +1 -1
- package/dist/accessi-module/Dtos/ConsoleEntryDtos.d.ts +24 -0
- package/dist/accessi-module/Dtos/ConsoleEntryDtos.js +77 -0
- package/dist/accessi-module/Dtos/ConsoleEntryDtos.js.map +1 -0
- package/dist/accessi-module/Dtos/SetUserPasswordRequest.d.ts +4 -0
- package/dist/accessi-module/Dtos/SetUserPasswordRequest.js +32 -0
- package/dist/accessi-module/Dtos/SetUserPasswordRequest.js.map +1 -0
- package/dist/accessi-module/Services/AuthService/AuthService.d.ts +8 -2
- package/dist/accessi-module/Services/AuthService/AuthService.js +13 -9
- package/dist/accessi-module/Services/AuthService/AuthService.js.map +1 -1
- package/dist/accessi-module/Services/UserService/UserService.d.ts +15 -0
- package/dist/accessi-module/Services/UserService/UserService.js +126 -55
- package/dist/accessi-module/Services/UserService/UserService.js.map +1 -1
- package/dist/accessi-module/Views/reset-password.html +23 -7
- package/dist/accessi-module/federated-auth/FederatedAuthController.d.ts +10 -1
- package/dist/accessi-module/federated-auth/FederatedAuthController.js +50 -10
- package/dist/accessi-module/federated-auth/FederatedAuthController.js.map +1 -1
- package/dist/accessi-module/federated-auth/FederatedAuthService.d.ts +2 -0
- package/dist/accessi-module/federated-auth/FederatedAuthService.js +10 -0
- package/dist/accessi-module/federated-auth/FederatedAuthService.js.map +1 -1
- package/dist/accessi-module/security/accessControl.d.ts +26 -0
- package/dist/accessi-module/security/accessControl.js +37 -0
- package/dist/accessi-module/security/accessControl.js.map +1 -1
- package/dist/accessi-module/security/consoleEntry.d.ts +16 -0
- package/dist/accessi-module/security/consoleEntry.js +50 -0
- package/dist/accessi-module/security/consoleEntry.js.map +1 -0
- package/dist/accessi-module/security/passwordPolicy.d.ts +21 -0
- package/dist/accessi-module/security/passwordPolicy.js +71 -0
- package/dist/accessi-module/security/passwordPolicy.js.map +1 -0
- package/dist/accessi-module/security/publicAuthRateLimit.d.ts +1 -1
- package/dist/accessi-module/security/publicAuthRateLimit.js +1 -0
- package/dist/accessi-module/security/publicAuthRateLimit.js.map +1 -1
- package/dist/emilsoftware-utilities-2.0.0-dev.43.tgz +0 -0
- package/package.json +1 -1
- package/dist/emilsoftware-utilities-2.0.0-dev.41.tgz +0 -0
|
@@ -34,23 +34,43 @@ const PublicRegisterRequest_1 = require("../Dtos/PublicRegisterRequest");
|
|
|
34
34
|
const RegisterResponse_1 = require("../Dtos/RegisterResponse");
|
|
35
35
|
const RegisterRequest_1 = require("../Dtos/RegisterRequest");
|
|
36
36
|
const SetStatoRegistrazione_1 = require("../Dtos/SetStatoRegistrazione");
|
|
37
|
+
const SetUserPasswordRequest_1 = require("../Dtos/SetUserPasswordRequest");
|
|
37
38
|
const UserDto_1 = require("../Dtos/UserDto");
|
|
39
|
+
const AuthService_1 = require("../Services/AuthService/AuthService");
|
|
38
40
|
const EmailService_1 = require("../Services/EmailService/EmailService");
|
|
39
41
|
const UserService_1 = require("../Services/UserService/UserService");
|
|
40
42
|
const jwt_strategy_1 = require("../jwt/jwt.strategy");
|
|
41
43
|
const publicAuthRateLimit_1 = require("../security/publicAuthRateLimit");
|
|
42
44
|
const accessControl_1 = require("../security/accessControl");
|
|
45
|
+
const emailConfiguration_1 = require("../security/emailConfiguration");
|
|
46
|
+
const StatoRegistrazione_1 = require("../Dtos/StatoRegistrazione");
|
|
43
47
|
let UserController = UserController_1 = class UserController {
|
|
44
|
-
constructor(accessiOptions, userService, emailService) {
|
|
48
|
+
constructor(accessiOptions, userService, emailService, authService) {
|
|
45
49
|
this.accessiOptions = accessiOptions;
|
|
46
50
|
this.userService = userService;
|
|
47
51
|
this.emailService = emailService;
|
|
52
|
+
this.authService = authService;
|
|
48
53
|
this.logger = new Logger_1.Logger(UserController_1.name);
|
|
49
54
|
}
|
|
50
55
|
sendControllerError(res, error) {
|
|
51
56
|
// Lo status viene derivato centralmente da RestUtilities (HttpException o 500).
|
|
52
57
|
return Utilities_1.RestUtilities.sendErrorMessage(res, error, UserController_1.name);
|
|
53
58
|
}
|
|
59
|
+
/**
|
|
60
|
+
* Verifica che il target esista e che l'attore possa gestirlo (rango attore >=
|
|
61
|
+
* rango target: ADMIN > SUPER > utente). Restituisce lo snapshot corrente del
|
|
62
|
+
* target, così i chiamanti possono controllare se e' admin.
|
|
63
|
+
*/
|
|
64
|
+
ensureManageableTarget(actor, codiceUtente) {
|
|
65
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
66
|
+
const target = yield this.userService.getAuthenticatedUserSnapshot(codiceUtente);
|
|
67
|
+
if (!target) {
|
|
68
|
+
throw new common_1.NotFoundException(`Nessun utente con codice ${codiceUtente}.`);
|
|
69
|
+
}
|
|
70
|
+
(0, accessControl_1.ensureCanManageTargetUser)(actor, target);
|
|
71
|
+
return target;
|
|
72
|
+
});
|
|
73
|
+
}
|
|
54
74
|
serveResetPasswordPage(res, _token) {
|
|
55
75
|
return __awaiter(this, void 0, void 0, function* () {
|
|
56
76
|
return res.sendFile((0, path_1.join)(__dirname, '..', 'Views', 'reset-password.html'));
|
|
@@ -79,7 +99,12 @@ let UserController = UserController_1 = class UserController {
|
|
|
79
99
|
deleteUser(request, codiceUtente, res) {
|
|
80
100
|
return __awaiter(this, void 0, void 0, function* () {
|
|
81
101
|
try {
|
|
82
|
-
|
|
102
|
+
const authenticatedUser = (0, accessControl_1.getAuthenticatedAccessiUser)(request);
|
|
103
|
+
(0, accessControl_1.ensureUserManagement)(authenticatedUser, 'Solo gli amministratori possono eliminare utenti.');
|
|
104
|
+
const target = yield this.ensureManageableTarget(authenticatedUser, codiceUtente);
|
|
105
|
+
if (target.flagAdmin) {
|
|
106
|
+
yield this.userService.assertNotLastActiveAdmin(codiceUtente);
|
|
107
|
+
}
|
|
83
108
|
yield this.userService.deleteUser(codiceUtente);
|
|
84
109
|
return Utilities_1.RestUtilities.sendOKMessage(res, "L'utente e' stato eliminato con successo.");
|
|
85
110
|
}
|
|
@@ -88,10 +113,32 @@ let UserController = UserController_1 = class UserController {
|
|
|
88
113
|
}
|
|
89
114
|
});
|
|
90
115
|
}
|
|
116
|
+
deleteUserPermanently(request, codiceUtente, res) {
|
|
117
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
118
|
+
try {
|
|
119
|
+
const authenticatedUser = (0, accessControl_1.getAuthenticatedAccessiUser)(request);
|
|
120
|
+
(0, accessControl_1.ensureAdmin)(authenticatedUser, 'Solo gli admin possono eliminare definitivamente un utente.');
|
|
121
|
+
if (authenticatedUser.codiceUtente === codiceUtente) {
|
|
122
|
+
throw new common_1.BadRequestException('Non puoi eliminare definitivamente il tuo stesso utente.');
|
|
123
|
+
}
|
|
124
|
+
const target = yield this.ensureManageableTarget(authenticatedUser, codiceUtente);
|
|
125
|
+
if (target.flagAdmin) {
|
|
126
|
+
yield this.userService.assertNotLastActiveAdmin(codiceUtente);
|
|
127
|
+
}
|
|
128
|
+
yield this.userService.deleteUserPermanently(codiceUtente);
|
|
129
|
+
return Utilities_1.RestUtilities.sendOKMessage(res, "L'utente e' stato eliminato definitivamente.");
|
|
130
|
+
}
|
|
131
|
+
catch (error) {
|
|
132
|
+
return this.sendControllerError(res, error);
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
}
|
|
91
136
|
forcePasswordReset(request, codiceUtente, res) {
|
|
92
137
|
return __awaiter(this, void 0, void 0, function* () {
|
|
93
138
|
try {
|
|
94
|
-
|
|
139
|
+
const authenticatedUser = (0, accessControl_1.getAuthenticatedAccessiUser)(request);
|
|
140
|
+
(0, accessControl_1.ensureUserManagement)(authenticatedUser, 'Solo gli amministratori possono forzare il reset password.');
|
|
141
|
+
yield this.ensureManageableTarget(authenticatedUser, codiceUtente);
|
|
95
142
|
yield this.userService.forcePasswordReset(codiceUtente);
|
|
96
143
|
return Utilities_1.RestUtilities.sendOKMessage(res, `Email di reset inviata all utente ${codiceUtente}.`);
|
|
97
144
|
}
|
|
@@ -112,16 +159,37 @@ let UserController = UserController_1 = class UserController {
|
|
|
112
159
|
}
|
|
113
160
|
});
|
|
114
161
|
}
|
|
162
|
+
setUserPassword(request, codiceUtente, body, res) {
|
|
163
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
164
|
+
try {
|
|
165
|
+
const authenticatedUser = (0, accessControl_1.getAuthenticatedAccessiUser)(request);
|
|
166
|
+
(0, accessControl_1.ensureUserManagement)(authenticatedUser, 'Solo gli amministratori possono impostare la password di un utente.');
|
|
167
|
+
yield this.ensureManageableTarget(authenticatedUser, codiceUtente);
|
|
168
|
+
yield this.authService.setPassword(codiceUtente, body.newPassword);
|
|
169
|
+
return Utilities_1.RestUtilities.sendOKMessage(res, `Password dell utente ${codiceUtente} aggiornata.`);
|
|
170
|
+
}
|
|
171
|
+
catch (error) {
|
|
172
|
+
return this.sendControllerError(res, error);
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
}
|
|
115
176
|
setStatoRegistrazione(request, body, res) {
|
|
116
177
|
return __awaiter(this, void 0, void 0, function* () {
|
|
117
178
|
try {
|
|
118
|
-
|
|
179
|
+
const authenticatedUser = (0, accessControl_1.getAuthenticatedAccessiUser)(request);
|
|
180
|
+
(0, accessControl_1.ensureUserManagement)(authenticatedUser, 'Solo gli amministratori possono modificare lo stato di registrazione.');
|
|
119
181
|
const { codiceUtente, statoRegistrazione } = body;
|
|
120
182
|
if (!codiceUtente)
|
|
121
183
|
throw new common_1.BadRequestException('Il codice utente e\' obbligatorio.');
|
|
122
184
|
if (statoRegistrazione === undefined) {
|
|
123
185
|
throw new common_1.BadRequestException('Lo stato registrazione e\' obbligatorio.');
|
|
124
186
|
}
|
|
187
|
+
const target = yield this.ensureManageableTarget(authenticatedUser, codiceUtente);
|
|
188
|
+
const disabling = statoRegistrazione === StatoRegistrazione_1.StatoRegistrazione.DELETE
|
|
189
|
+
|| statoRegistrazione === StatoRegistrazione_1.StatoRegistrazione.BLOCC;
|
|
190
|
+
if (target.flagAdmin && disabling) {
|
|
191
|
+
yield this.userService.assertNotLastActiveAdmin(codiceUtente);
|
|
192
|
+
}
|
|
125
193
|
yield this.userService.setStato(codiceUtente, statoRegistrazione);
|
|
126
194
|
return Utilities_1.RestUtilities.sendOKMessage(res, `Lo stato dell'utente ${codiceUtente} e' stato aggiornato a ${statoRegistrazione}.`);
|
|
127
195
|
}
|
|
@@ -141,10 +209,25 @@ let UserController = UserController_1 = class UserController {
|
|
|
141
209
|
if (!rateLimitDecision.allowed) {
|
|
142
210
|
return (0, publicAuthRateLimit_1.sendPublicAuthRateLimitExceeded)(res, rateLimitDecision.retryAfterSeconds);
|
|
143
211
|
}
|
|
212
|
+
(0, emailConfiguration_1.assertEmailConfigured)(this.accessiOptions);
|
|
144
213
|
const codiceUtente = yield this.userService.register(registrationData, {
|
|
145
214
|
allowPrivilegedFields: false,
|
|
146
215
|
});
|
|
147
|
-
|
|
216
|
+
try {
|
|
217
|
+
yield this.emailService.sendPasswordResetEmail(registrationData.email);
|
|
218
|
+
}
|
|
219
|
+
catch (emailError) {
|
|
220
|
+
try {
|
|
221
|
+
yield this.userService.deleteUserPermanently(codiceUtente);
|
|
222
|
+
}
|
|
223
|
+
catch (rollbackError) {
|
|
224
|
+
this.logger.error(`Rollback registrazione utente ${codiceUtente} non riuscita: ${rollbackError instanceof Error ? rollbackError.message : String(rollbackError)}`);
|
|
225
|
+
}
|
|
226
|
+
throw new common_1.BadRequestException({
|
|
227
|
+
code: 'ACCESSI_USER_INVITE_EMAIL_FAILED',
|
|
228
|
+
message: `Registrazione non completata: invio email non riuscito (${emailError instanceof Error ? emailError.message : String(emailError)}). Riprova piu tardi.`,
|
|
229
|
+
});
|
|
230
|
+
}
|
|
148
231
|
return Utilities_1.RestUtilities.sendBaseResponse(res, codiceUtente, common_1.HttpStatus.CREATED);
|
|
149
232
|
}
|
|
150
233
|
catch (error) {
|
|
@@ -156,9 +239,29 @@ let UserController = UserController_1 = class UserController {
|
|
|
156
239
|
createManagedUser(request, registrationData, res) {
|
|
157
240
|
return __awaiter(this, void 0, void 0, function* () {
|
|
158
241
|
try {
|
|
159
|
-
|
|
242
|
+
const authenticatedUser = (0, accessControl_1.getAuthenticatedAccessiUser)(request);
|
|
243
|
+
(0, accessControl_1.ensureUserManagement)(authenticatedUser, 'Solo gli amministratori possono creare utenti.');
|
|
244
|
+
(0, accessControl_1.ensurePrivilegeFlagChanges)(authenticatedUser, registrationData);
|
|
245
|
+
// Fail-fast prima di scrivere: senza SMTP non si crea un utente orfano.
|
|
246
|
+
(0, emailConfiguration_1.assertEmailConfigured)(this.accessiOptions);
|
|
160
247
|
const codiceUtente = yield this.userService.register(registrationData, { allowPrivilegedFields: true });
|
|
161
|
-
|
|
248
|
+
try {
|
|
249
|
+
yield this.emailService.sendPasswordResetEmail(registrationData.email, registrationData.htmlMail);
|
|
250
|
+
}
|
|
251
|
+
catch (emailError) {
|
|
252
|
+
// L'invio e' esterno: se fallisce annulliamo la creazione per non lasciare un utente
|
|
253
|
+
// senza password e senza email di invito (rollback best-effort).
|
|
254
|
+
try {
|
|
255
|
+
yield this.userService.deleteUserPermanently(codiceUtente);
|
|
256
|
+
}
|
|
257
|
+
catch (rollbackError) {
|
|
258
|
+
this.logger.error(`Rollback creazione utente ${codiceUtente} non riuscita: ${rollbackError instanceof Error ? rollbackError.message : String(rollbackError)}`);
|
|
259
|
+
}
|
|
260
|
+
throw new common_1.BadRequestException({
|
|
261
|
+
code: 'ACCESSI_USER_INVITE_EMAIL_FAILED',
|
|
262
|
+
message: `Utente non creato: invio email di invito non riuscito (${emailError instanceof Error ? emailError.message : String(emailError)}). Riprova oppure crea l utente e imposta la password manualmente.`,
|
|
263
|
+
});
|
|
264
|
+
}
|
|
162
265
|
return Utilities_1.RestUtilities.sendBaseResponse(res, codiceUtente, common_1.HttpStatus.CREATED);
|
|
163
266
|
}
|
|
164
267
|
catch (error) {
|
|
@@ -171,8 +274,17 @@ let UserController = UserController_1 = class UserController {
|
|
|
171
274
|
try {
|
|
172
275
|
const authenticatedUser = (0, accessControl_1.getAuthenticatedAccessiUser)(request);
|
|
173
276
|
const isPrivilegedUpdate = (0, accessControl_1.hasPrivilegedUserChanges)(user);
|
|
277
|
+
const isSelf = authenticatedUser.codiceUtente === codiceUtente;
|
|
278
|
+
// ADMIN > SUPER: un superutente non puo' toccare un admin. Self sempre consentito.
|
|
279
|
+
if (!isSelf) {
|
|
280
|
+
yield this.ensureManageableTarget(authenticatedUser, codiceUtente);
|
|
281
|
+
}
|
|
174
282
|
if (isPrivilegedUpdate) {
|
|
175
283
|
(0, accessControl_1.ensureUserManagement)(authenticatedUser, 'Solo gli amministratori possono modificare ruoli, permessi o flag privilegiati.');
|
|
284
|
+
(0, accessControl_1.ensurePrivilegeFlagChanges)(authenticatedUser, user);
|
|
285
|
+
if (user.flagAdmin === false) {
|
|
286
|
+
yield this.userService.assertNotLastActiveAdmin(codiceUtente);
|
|
287
|
+
}
|
|
176
288
|
}
|
|
177
289
|
else {
|
|
178
290
|
(0, accessControl_1.ensureSelfOrSuperUser)(authenticatedUser, codiceUtente, 'Puoi modificare solo il tuo profilo.');
|
|
@@ -193,7 +305,11 @@ let UserController = UserController_1 = class UserController {
|
|
|
193
305
|
setGdpr(request, codiceUtente, res) {
|
|
194
306
|
return __awaiter(this, void 0, void 0, function* () {
|
|
195
307
|
try {
|
|
196
|
-
|
|
308
|
+
const authenticatedUser = (0, accessControl_1.getAuthenticatedAccessiUser)(request);
|
|
309
|
+
(0, accessControl_1.ensureSelfOrSuperUser)(authenticatedUser, codiceUtente, 'Puoi impostare il GDPR solo sul tuo utente.');
|
|
310
|
+
if (authenticatedUser.codiceUtente !== codiceUtente) {
|
|
311
|
+
yield this.ensureManageableTarget(authenticatedUser, codiceUtente);
|
|
312
|
+
}
|
|
197
313
|
yield this.userService.setGdpr(codiceUtente);
|
|
198
314
|
return Utilities_1.RestUtilities.sendOKMessage(res, `L'utente ${codiceUtente} ha accettato il GDPR.`);
|
|
199
315
|
}
|
|
@@ -314,6 +430,33 @@ __decorate([
|
|
|
314
430
|
__metadata("design:paramtypes", [Object, Number, Object]),
|
|
315
431
|
__metadata("design:returntype", Promise)
|
|
316
432
|
], UserController.prototype, "deleteUser", null);
|
|
433
|
+
__decorate([
|
|
434
|
+
(0, swagger_1.ApiOperation)({
|
|
435
|
+
summary: 'Elimina definitivamente un utente',
|
|
436
|
+
operationId: 'deleteUserPermanently',
|
|
437
|
+
description: 'Rimuove l utente e tutti i record collegati. Operazione distruttiva riservata agli admin.',
|
|
438
|
+
}),
|
|
439
|
+
(0, swagger_1.ApiParam)({
|
|
440
|
+
name: 'codiceUtente',
|
|
441
|
+
description: "Codice identificativo dell'utente da eliminare definitivamente",
|
|
442
|
+
required: true,
|
|
443
|
+
example: 123,
|
|
444
|
+
}),
|
|
445
|
+
(0, swagger_1.ApiResponse)({ status: 200, description: 'Utente eliminato definitivamente', type: BaseResponse_1.ActionResponse }),
|
|
446
|
+
(0, swagger_1.ApiResponse)({ status: 400, description: 'Errore nei parametri della richiesta', type: BaseResponse_1.ErrorResponse }),
|
|
447
|
+
(0, swagger_1.ApiResponse)({ status: 403, description: 'Operazione non autorizzata', type: BaseResponse_1.ErrorResponse }),
|
|
448
|
+
(0, swagger_1.ApiResponse)({ status: 404, description: 'Utente non trovato', type: BaseResponse_1.ErrorResponse }),
|
|
449
|
+
(0, swagger_1.ApiResponse)({ status: 500, description: 'Errore interno del server', type: BaseResponse_1.ErrorResponse }),
|
|
450
|
+
(0, swagger_1.ApiBearerAuth)(),
|
|
451
|
+
(0, common_1.UseGuards)(jwt_strategy_1.JwtSimpleGuard),
|
|
452
|
+
(0, common_1.Delete)('delete-user-permanent/:codiceUtente'),
|
|
453
|
+
__param(0, (0, common_1.Req)()),
|
|
454
|
+
__param(1, (0, common_1.Param)('codiceUtente', common_1.ParseIntPipe)),
|
|
455
|
+
__param(2, (0, common_1.Res)()),
|
|
456
|
+
__metadata("design:type", Function),
|
|
457
|
+
__metadata("design:paramtypes", [Object, Number, Object]),
|
|
458
|
+
__metadata("design:returntype", Promise)
|
|
459
|
+
], UserController.prototype, "deleteUserPermanently", null);
|
|
317
460
|
__decorate([
|
|
318
461
|
(0, swagger_1.ApiOperation)({
|
|
319
462
|
summary: 'Forza l invio dell email di reset password a un utente',
|
|
@@ -351,6 +494,28 @@ __decorate([
|
|
|
351
494
|
__metadata("design:paramtypes", [Object, Object]),
|
|
352
495
|
__metadata("design:returntype", Promise)
|
|
353
496
|
], UserController.prototype, "forcePasswordResetLegacy", null);
|
|
497
|
+
__decorate([
|
|
498
|
+
(0, swagger_1.ApiOperation)({
|
|
499
|
+
summary: 'Imposta direttamente la password di un utente',
|
|
500
|
+
operationId: 'setUserPassword',
|
|
501
|
+
description: 'Riservato agli amministratori. Hasha la password, aggiorna la scadenza secondo la policy e non invia email.',
|
|
502
|
+
}),
|
|
503
|
+
(0, swagger_1.ApiParam)({ name: 'codiceUtente', description: 'Codice identificativo dell utente', required: true, example: 123, type: Number }),
|
|
504
|
+
(0, swagger_1.ApiBody)({ type: SetUserPasswordRequest_1.SetUserPasswordRequest }),
|
|
505
|
+
(0, swagger_1.ApiResponse)({ status: 200, description: 'Password aggiornata', type: BaseResponse_1.ActionResponse }),
|
|
506
|
+
(0, swagger_1.ApiResponse)({ status: 400, description: 'Password non valida', type: BaseResponse_1.ErrorResponse }),
|
|
507
|
+
(0, swagger_1.ApiResponse)({ status: 403, description: 'Operazione non autorizzata', type: BaseResponse_1.ErrorResponse }),
|
|
508
|
+
(0, swagger_1.ApiBearerAuth)(),
|
|
509
|
+
(0, common_1.UseGuards)(jwt_strategy_1.JwtSimpleGuard),
|
|
510
|
+
(0, common_1.Post)('set-password/:codiceUtente'),
|
|
511
|
+
__param(0, (0, common_1.Req)()),
|
|
512
|
+
__param(1, (0, common_1.Param)('codiceUtente', common_1.ParseIntPipe)),
|
|
513
|
+
__param(2, (0, common_1.Body)()),
|
|
514
|
+
__param(3, (0, common_1.Res)()),
|
|
515
|
+
__metadata("design:type", Function),
|
|
516
|
+
__metadata("design:paramtypes", [Object, Number, SetUserPasswordRequest_1.SetUserPasswordRequest, Object]),
|
|
517
|
+
__metadata("design:returntype", Promise)
|
|
518
|
+
], UserController.prototype, "setUserPassword", null);
|
|
354
519
|
__decorate([
|
|
355
520
|
(0, swagger_1.ApiOperation)({
|
|
356
521
|
summary: 'Imposta lo stato di registrazione di un utente',
|
|
@@ -500,6 +665,7 @@ exports.UserController = UserController = UserController_1 = __decorate([
|
|
|
500
665
|
,
|
|
501
666
|
__param(0, (0, common_1.Inject)('ACCESSI_OPTIONS')),
|
|
502
667
|
__metadata("design:paramtypes", [Object, UserService_1.UserService,
|
|
503
|
-
EmailService_1.EmailService
|
|
668
|
+
EmailService_1.EmailService,
|
|
669
|
+
AuthService_1.AuthService])
|
|
504
670
|
], UserController);
|
|
505
671
|
//# sourceMappingURL=UserController.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserController.js","sourceRoot":"","sources":["../../../src/accessi-module/Controllers/UserController.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAmBwB;AAExB,6CASyB;AACzB,+BAA4B;AAC5B,yCAAsC;AACtC,+CAAgD;AAEhD,uDAAqE;AACrE,+DAA4D;AAC5D,yEAAsE;AACtE,+DAA4D;AAC5D,6DAA0D;AAC1D,yEAAyE;AACzE,6CAA0C;AAC1C,wEAAqE;AACrE,qEAAkE;AAClE,sDAAqD;AACrD,yEAGyC;AACzC,6DAKmC;AAQ5B,IAAM,cAAc,sBAApB,MAAM,cAAc;IAGzB,YAC6B,cAA+C,EACzD,WAAwB,EACxB,YAA0B;QAFC,mBAAc,GAAd,cAAc,CAAgB;QACzD,gBAAW,GAAX,WAAW,CAAa;QACxB,iBAAY,GAAZ,YAAY,CAAc;QAL5B,WAAM,GAAG,IAAI,eAAM,CAAC,gBAAc,CAAC,IAAI,CAAC,CAAC;IAMvD,CAAC;IAEI,mBAAmB,CAAC,GAAa,EAAE,KAAc;QACvD,gFAAgF;QAChF,OAAO,yBAAa,CAAC,gBAAgB,CAAC,GAAG,EAAE,KAAK,EAAE,gBAAc,CAAC,IAAI,CAAC,CAAC;IACzE,CAAC;IAYK,sBAAsB,CAAQ,GAAa,EAAkB,MAAc;;YAC/E,OAAO,GAAG,CAAC,QAAQ,CAAC,IAAA,WAAI,EAAC,SAAS,EAAE,IAAI,EAAE,OAAO,EA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AC5F,IAAA,uBAAa,GAAE;IACf,IAAA,kBAAS,EAAC,6BAAc,CAAC;IACzB,IAAA,cAAK,EAAC,wBAAwB,CAAC;IAE7B,WAAA,IAAA,YAAG,GAAE,CAAA;IACL,WAAA,IAAA,cAAK,EAAC,cAAc,EAAE,qBAAY,CAAC,CAAA;IACnC,WAAA,IAAA,YAAG,GAAE,CAAA;;;;6CAcP;yBAlbU,cAAc;IAN1B,IAAA,iBAAO,EAAC,MAAM,CAAC;IACf,IAAA,mBAAU,EAAC,cAAc,CAAC;IAC3B;;;OAGG;;IAKE,WAAA,IAAA,eAAM,EAAC,iBAAiB,CAAC,CAAA;6CACI,yBAAW;QACV,2BAAY;GANlC,cAAc,CAmb1B","sourcesContent":["import {\n BadRequestException,\n Body,\n Controller,\n Delete,\n Get,\n HttpException,\n HttpStatus,\n Param,\n ParseBoolPipe,\n ParseIntPipe,\n Patch,\n Post,\n Put,\n Query,\n Inject,\n Req,\n Res,\n UseGuards,\n} from '@nestjs/common';\nimport { Request, Response } from 'express';\nimport {\n ApiBearerAuth,\n ApiBody,\n ApiCreatedResponse,\n ApiOperation,\n ApiParam,\n ApiQuery,\n ApiResponse,\n ApiTags,\n} from '@nestjs/swagger';\nimport { join } from 'path';\nimport { Logger } from '../../Logger';\nimport { RestUtilities } from '../../Utilities';\nimport type { AccessiOptions } from '../AccessiModule';\nimport { ActionResponse, ErrorResponse } from '../Dtos/BaseResponse';\nimport { GetUsersResponse } from '../Dtos/GetUsersResponse';\nimport { PublicRegisterRequest } from '../Dtos/PublicRegisterRequest';\nimport { RegisterResponse } from '../Dtos/RegisterResponse';\nimport { RegisterRequest } from '../Dtos/RegisterRequest';\nimport { SetStatoRegistrazioneDto } from '../Dtos/SetStatoRegistrazione';\nimport { UserDto } from '../Dtos/UserDto';\nimport { EmailService } from '../Services/EmailService/EmailService';\nimport { UserService } from '../Services/UserService/UserService';\nimport { JwtSimpleGuard } from '../jwt/jwt.strategy';\nimport {\n checkPublicAuthRateLimit,\n sendPublicAuthRateLimitExceeded,\n} from '../security/publicAuthRateLimit';\nimport {\n ensureSelfOrSuperUser,\n ensureUserManagement,\n getAuthenticatedAccessiUser,\n hasPrivilegedUserChanges,\n} from '../security/accessControl';\n\n@ApiTags('User')\n@Controller('accessi/user')\n/**\n * Gestione utenti: la registrazione pubblica e opt-in, mentre creazione, stato e profili privilegiati\n * richiedono un superutente Accessi. Le API restituiscono sempre il wrapper `BaseResponse` storico.\n */\nexport class UserController {\n private readonly logger = new Logger(UserController.name);\n\n constructor(\n @Inject('ACCESSI_OPTIONS') private readonly accessiOptions: AccessiOptions,\n private readonly userService: UserService,\n private readonly emailService: EmailService,\n ) {}\n\n private sendControllerError(res: Response, error: unknown) {\n // Lo status viene derivato centralmente da RestUtilities (HttpException o 500).\n return RestUtilities.sendErrorMessage(res, error, UserController.name);\n }\n\n @ApiOperation({\n summary: 'Serve la pagina di reset password',\n operationId: 'serveResetPasswordPageUser',\n })\n @ApiParam({\n name: 'token',\n description: 'Token per il reset della password',\n required: true,\n })\n @Get('reset-password/:token')\n async serveResetPasswordPage(@Res() res: Response, @Param('token') _token: string) {\n return res.sendFile(join(__dirname, '..', 'Views', 'reset-password.html'));\n }\n\n @ApiOperation({\n summary: 'Recupera la lista degli utenti',\n operationId: 'getUsers',\n })\n @ApiResponse({\n status: 200,\n description: 'Lista utenti recuperata con successo',\n type: GetUsersResponse,\n })\n @ApiResponse({ status: 401, description: 'Credenziali non valide', type: ErrorResponse })\n @ApiResponse({ status: 403, description: 'Operazione non autorizzata', type: ErrorResponse })\n @ApiResponse({ status: 500, description: 'Errore interno del server', type: ErrorResponse })\n @ApiQuery({\n name: 'email',\n required: false,\n description: \"Email dell'utente da cercare\",\n type: String,\n })\n @ApiQuery({\n name: 'codiceUtente',\n required: false,\n description: \"Codice dell'utente da cercare\",\n type: Number,\n })\n @ApiQuery({\n name: 'includeExtensionFields',\n required: false,\n description: 'Includi extension fields',\n type: Boolean,\n })\n @ApiQuery({\n name: 'includeGrants',\n required: false,\n description: 'Includi permessi',\n type: Boolean,\n })\n @ApiQuery({\n name: 'limit',\n required: false,\n description: 'Numero massimo di utenti restituiti (1-1000). Omesso = tutti.',\n type: Number,\n })\n @ApiQuery({\n name: 'offset',\n required: false,\n description: 'Numero di utenti da saltare (paginazione).',\n type: Number,\n })\n @ApiBearerAuth()\n @UseGuards(JwtSimpleGuard)\n @Get('get-users')\n async getUsers(\n @Req() request: Request,\n @Res() res: Response,\n @Query('email') email?: string,\n @Query('codiceUtente', new ParseIntPipe({ optional: true })) codiceUtente?: number,\n @Query('includeExtensionFields', new ParseBoolPipe({ optional: true }))\n includeExtensionFields?: boolean,\n @Query('includeGrants', new ParseBoolPipe({ optional: true }))\n includeGrants?: boolean,\n @Query('limit', new ParseIntPipe({ optional: true })) limit?: number,\n @Query('offset', new ParseIntPipe({ optional: true })) offset?: number,\n ) {\n try {\n ensureUserManagement(\n getAuthenticatedAccessiUser(request),\n 'Solo gli amministratori possono consultare gli utenti.',\n );\n\n const filters = { email, codiceUtente, limit, offset };\n const options = {\n includeExtensionFields: includeExtensionFields ?? true,\n includeGrants: includeGrants ?? true,\n };\n\n const users = await this.userService.getUsers(filters, options);\n const total = await this.userService.countUsers({ email, codiceUtente });\n res.setHeader('X-Total-Count', String(total));\n return RestUtilities.sendBaseResponse(res, users);\n } catch (error) {\n this.logger.error('Errore durante il recupero degli utenti: ', error);\n return this.sendControllerError(res, error);\n }\n }\n\n @ApiOperation({\n summary: 'Elimina un utente',\n operationId: 'deleteUser',\n description: 'Imposta lo stato di un utente a eliminato senza rimuovere i record.',\n })\n @ApiParam({\n name: 'codiceUtente',\n description: \"Codice identificativo dell'utente da eliminare\",\n required: true,\n example: 123,\n })\n @ApiResponse({ status: 200, description: 'Utente eliminato con successo', type: ActionResponse })\n @ApiResponse({\n status: 400,\n description: 'Errore nei parametri della richiesta',\n type: ErrorResponse,\n })\n @ApiResponse({ status: 500, description: 'Errore interno del server', type: ErrorResponse })\n @ApiBearerAuth()\n @UseGuards(JwtSimpleGuard)\n @Delete('delete-user/:codiceUtente')\n async deleteUser(\n @Req() request: Request,\n @Param('codiceUtente', ParseIntPipe) codiceUtente: number,\n @Res() res: Response,\n ) {\n try {\n ensureUserManagement(\n getAuthenticatedAccessiUser(request),\n 'Solo gli amministratori possono eliminare utenti.',\n );\n\n await this.userService.deleteUser(codiceUtente);\n return RestUtilities.sendOKMessage(res, \"L'utente e' stato eliminato con successo.\");\n } catch (error) {\n return this.sendControllerError(res, error);\n }\n }\n\n @ApiOperation({\n summary: 'Forza l invio dell email di reset password a un utente',\n operationId: 'forcePasswordReset',\n description: 'Riservato al superutente. Richiede un servizio email configurato; altrimenti risponde con ACCESSI_EMAIL_NOT_CONFIGURED.',\n })\n @ApiParam({ name: 'codiceUtente', description: 'Codice identificativo dell utente', required: true, example: 123, type: Number })\n @ApiResponse({ status: 200, description: 'Email di reset inviata', type: ActionResponse })\n @ApiResponse({ status: 400, description: 'Servizio email non configurato', type: ErrorResponse })\n @ApiResponse({ status: 404, description: 'Utente non trovato', type: ErrorResponse })\n @ApiBearerAuth()\n @UseGuards(JwtSimpleGuard)\n @Post('force-password-reset/:codiceUtente')\n async forcePasswordReset(\n @Req() request: Request,\n @Param('codiceUtente', ParseIntPipe) codiceUtente: number,\n @Res() res: Response,\n ) {\n try {\n ensureUserManagement(\n getAuthenticatedAccessiUser(request),\n 'Solo gli amministratori possono forzare il reset password.',\n );\n await this.userService.forcePasswordReset(codiceUtente);\n return RestUtilities.sendOKMessage(res, `Email di reset inviata all utente ${codiceUtente}.`);\n } catch (error) {\n return this.sendControllerError(res, error);\n }\n }\n\n @ApiOperation({\n summary: 'Forza il reset password per tutti gli utenti con password legacy',\n operationId: 'forcePasswordResetLegacy',\n description: 'Riservato al superutente. Invia l email di reset a tutti gli utenti la cui password non e ancora nel formato moderno. Richiede un servizio email configurato.',\n })\n @ApiResponse({ status: 200, description: 'Email di reset inviate', type: ActionResponse })\n @ApiResponse({ status: 400, description: 'Servizio email non configurato', type: ErrorResponse })\n @ApiBearerAuth()\n @UseGuards(JwtSimpleGuard)\n @Post('force-password-reset-legacy')\n async forcePasswordResetLegacy(@Req() request: Request, @Res() res: Response) {\n try {\n ensureUserManagement(\n getAuthenticatedAccessiUser(request),\n 'Solo gli amministratori possono forzare il reset password.',\n );\n const sent = await this.userService.forcePasswordResetForLegacyPasswords();\n return RestUtilities.sendOKMessage(res, `Email di reset inviata a ${sent} utenti con password legacy.`);\n } catch (error) {\n return this.sendControllerError(res, error);\n }\n }\n\n @ApiOperation({\n summary: 'Imposta lo stato di registrazione di un utente',\n operationId: 'setStatoRegistrazione',\n })\n @ApiResponse({\n status: 200,\n description: 'Stato registrazione aggiornato con successo',\n type: ActionResponse,\n })\n @ApiResponse({\n status: 400,\n description: 'Errore nei parametri della richiesta',\n type: ErrorResponse,\n })\n @ApiResponse({\n status: 500,\n description: 'Errore interno del server',\n type: ErrorResponse,\n })\n @ApiBody({ type: SetStatoRegistrazioneDto })\n @ApiBearerAuth()\n @UseGuards(JwtSimpleGuard)\n @Post('set-stato')\n async setStatoRegistrazione(\n @Req() request: Request,\n @Body() body: SetStatoRegistrazioneDto,\n @Res() res: Response,\n ) {\n try {\n ensureUserManagement(\n getAuthenticatedAccessiUser(request),\n 'Solo gli amministratori possono modificare lo stato di registrazione.',\n );\n\n const { codiceUtente, statoRegistrazione } = body;\n if (!codiceUtente) throw new BadRequestException('Il codice utente e\\' obbligatorio.');\n if (statoRegistrazione === undefined) {\n throw new BadRequestException('Lo stato registrazione e\\' obbligatorio.');\n }\n\n await this.userService.setStato(codiceUtente, statoRegistrazione);\n return RestUtilities.sendOKMessage(\n res,\n `Lo stato dell'utente ${codiceUtente} e' stato aggiornato a ${statoRegistrazione}.`,\n );\n } catch (error) {\n return this.sendControllerError(res, error);\n }\n }\n\n @ApiOperation({\n summary: 'Registra un nuovo utente',\n description: 'Disponibile soltanto quando publicRegistration.enabled e true. Per utenti SSO usare il provisioning master nel tag Federated authentication.',\n operationId: 'register',\n })\n @ApiBody({\n type: PublicRegisterRequest,\n description: \"Dati necessari per la registrazione dell'utente\",\n })\n @ApiCreatedResponse({\n description:\n 'Utente registrato con successo. Restituisce il codice utente e invia una mail di reset password.',\n type: RegisterResponse,\n })\n @ApiResponse({\n status: HttpStatus.BAD_REQUEST,\n description: 'Errore nella registrazione.',\n type: ErrorResponse,\n })\n @ApiResponse({\n status: HttpStatus.INTERNAL_SERVER_ERROR,\n description: 'Errore interno del server durante la registrazione o l\\'invio email.',\n type: ErrorResponse,\n })\n @Post('register')\n async register(\n @Req() request: Request,\n @Body() registrationData: PublicRegisterRequest,\n @Res() res: Response,\n ) {\n try {\n if (this.accessiOptions.publicRegistration?.enabled !== true) {\n throw new HttpException(\n 'La registrazione pubblica e disabilitata. Un amministratore deve creare l utente.',\n HttpStatus.FORBIDDEN,\n );\n }\n\n const rateLimitDecision = checkPublicAuthRateLimit(\n this.accessiOptions,\n 'register',\n request,\n [registrationData?.email],\n );\n if (!rateLimitDecision.allowed) {\n return sendPublicAuthRateLimitExceeded(res, rateLimitDecision.retryAfterSeconds);\n }\n\n const codiceUtente = await this.userService.register(registrationData, {\n allowPrivilegedFields: false,\n });\n\n await this.emailService.sendPasswordResetEmail(registrationData.email);\n return RestUtilities.sendBaseResponse(res, codiceUtente, HttpStatus.CREATED);\n } catch (error) {\n const status =\n error instanceof HttpException ? error.getStatus() : HttpStatus.BAD_REQUEST;\n return RestUtilities.sendErrorMessage(res, error, UserController.name, status);\n }\n }\n\n @ApiOperation({ summary: 'Crea un utente locale da amministrazione', operationId: 'createManagedUser', description: 'Riservato a superutente. Crea un utente in attesa di impostazione password e invia la mail di reset.' })\n @ApiBody({ type: RegisterRequest })\n @ApiCreatedResponse({ type: RegisterResponse })\n @ApiBearerAuth()\n @UseGuards(JwtSimpleGuard)\n @Post('create-managed-user')\n async createManagedUser(@Req() request: Request, @Body() registrationData: RegisterRequest, @Res() res: Response) {\n try {\n ensureUserManagement(getAuthenticatedAccessiUser(request), 'Solo gli amministratori possono creare utenti.');\n const codiceUtente = await this.userService.register(registrationData, { allowPrivilegedFields: true });\n await this.emailService.sendPasswordResetEmail(registrationData.email, registrationData.htmlMail);\n return RestUtilities.sendBaseResponse(res, codiceUtente, HttpStatus.CREATED);\n } catch (error) {\n return this.sendControllerError(res, error);\n }\n }\n\n @ApiOperation({\n summary: 'Aggiorna un utente esistente',\n operationId: 'updateUtente',\n })\n @ApiParam({\n name: 'codiceUtente',\n description: \"Codice identificativo dell'utente da aggiornare\",\n required: true,\n example: 123,\n })\n @ApiBody({\n type: UserDto,\n description: \"Dati aggiornati dell'utente\",\n })\n @ApiResponse({\n status: HttpStatus.OK,\n description: 'Utente aggiornato con successo',\n type: ActionResponse,\n })\n @ApiResponse({ status: 400, description: \"Errore nell'aggiornamento\", type: ErrorResponse })\n @ApiResponse({ status: 403, description: 'Operazione non autorizzata', type: ErrorResponse })\n @ApiResponse({ status: 500, description: 'Errore interno del server', type: ErrorResponse })\n @ApiBearerAuth()\n @UseGuards(JwtSimpleGuard)\n @Put('update-user/:codiceUtente')\n async updateUtente(\n @Req() request: Request,\n @Param('codiceUtente', ParseIntPipe) codiceUtente: number,\n @Body() user: UserDto,\n @Res() res: Response,\n ) {\n try {\n const authenticatedUser = getAuthenticatedAccessiUser(request);\n const isPrivilegedUpdate = hasPrivilegedUserChanges(user);\n\n if (isPrivilegedUpdate) {\n ensureUserManagement(\n authenticatedUser,\n 'Solo gli amministratori possono modificare ruoli, permessi o flag privilegiati.',\n );\n } else {\n ensureSelfOrSuperUser(\n authenticatedUser,\n codiceUtente,\n 'Puoi modificare solo il tuo profilo.',\n );\n }\n\n if (user.codiceUtente !== undefined && user.codiceUtente !== codiceUtente) {\n throw new BadRequestException('Il codice utente nel body non coincide con quello del path.');\n }\n\n await this.userService.updateUser(codiceUtente, user, {\n allowPrivilegedChanges: authenticatedUser.flagSuper || authenticatedUser.flagAdmin,\n });\n\n return RestUtilities.sendOKMessage(\n res,\n `L'utente ${codiceUtente} e' stato aggiornato con successo.`,\n );\n } catch (error) {\n return this.sendControllerError(res, error);\n }\n }\n\n @ApiOperation({\n summary: 'Imposta il consenso GDPR per un utente',\n operationId: 'setGdpr',\n })\n @ApiParam({\n name: 'codiceUtente',\n description: \"Codice identificativo dell'utente che accetta il GDPR\",\n required: true,\n example: 123,\n })\n @ApiResponse({\n status: 200,\n description: 'Consenso GDPR impostato con successo',\n type: ActionResponse,\n })\n @ApiResponse({ status: 400, description: 'Errore nella richiesta', type: ErrorResponse })\n @ApiResponse({ status: 403, description: 'Operazione non autorizzata', type: ErrorResponse })\n @ApiBearerAuth()\n @UseGuards(JwtSimpleGuard)\n @Patch('set-gdpr/:codiceUtente')\n async setGdpr(\n @Req() request: Request,\n @Param('codiceUtente', ParseIntPipe) codiceUtente: number,\n @Res() res: Response,\n ) {\n try {\n ensureSelfOrSuperUser(\n getAuthenticatedAccessiUser(request),\n codiceUtente,\n 'Puoi impostare il GDPR solo sul tuo utente.',\n );\n\n await this.userService.setGdpr(codiceUtente);\n return RestUtilities.sendOKMessage(res, `L'utente ${codiceUtente} ha accettato il GDPR.`);\n } catch (error) {\n return this.sendControllerError(res, error);\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"UserController.js","sourceRoot":"","sources":["../../../src/accessi-module/Controllers/UserController.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAoBwB;AAExB,6CASyB;AACzB,+BAA4B;AAC5B,yCAAsC;AACtC,+CAAgD;AAEhD,uDAAqE;AACrE,+DAA4D;AAC5D,yEAAsE;AACtE,+DAA4D;AAC5D,6DAA0D;AAC1D,yEAAyE;AACzE,2EAAwE;AACxE,6CAA0C;AAC1C,qEAAkE;AAClE,wEAAqE;AACrE,qEAAkE;AAClE,sDAAqD;AACrD,yEAGyC;AACzC,6DAQmC;AAEnC,uEAAuE;AACvE,mEAAgE;AAQzD,IAAM,cAAc,sBAApB,MAAM,cAAc;IAGzB,YAC6B,cAA+C,EACz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AAC,cAAc,EAAE,qBAAY,CAAC,CAAA;IACnC,WAAA,IAAA,YAAG,GAAE,CAAA;;;;6CAkBP;yBArlBU,cAAc;IAN1B,IAAA,iBAAO,EAAC,MAAM,CAAC;IACf,IAAA,mBAAU,EAAC,cAAc,CAAC;IAC3B;;;OAGG;;IAKE,WAAA,IAAA,eAAM,EAAC,iBAAiB,CAAC,CAAA;6CACI,yBAAW;QACV,2BAAY;QACb,yBAAW;GAPhC,cAAc,CAslB1B","sourcesContent":["import {\n BadRequestException,\n Body,\n Controller,\n Delete,\n Get,\n HttpException,\n HttpStatus,\n NotFoundException,\n Param,\n ParseBoolPipe,\n ParseIntPipe,\n Patch,\n Post,\n Put,\n Query,\n Inject,\n Req,\n Res,\n UseGuards,\n} from '@nestjs/common';\nimport { Request, Response } from 'express';\nimport {\n ApiBearerAuth,\n ApiBody,\n ApiCreatedResponse,\n ApiOperation,\n ApiParam,\n ApiQuery,\n ApiResponse,\n ApiTags,\n} from '@nestjs/swagger';\nimport { join } from 'path';\nimport { Logger } from '../../Logger';\nimport { RestUtilities } from '../../Utilities';\nimport type { AccessiOptions } from '../AccessiModule';\nimport { ActionResponse, ErrorResponse } from '../Dtos/BaseResponse';\nimport { GetUsersResponse } from '../Dtos/GetUsersResponse';\nimport { PublicRegisterRequest } from '../Dtos/PublicRegisterRequest';\nimport { RegisterResponse } from '../Dtos/RegisterResponse';\nimport { RegisterRequest } from '../Dtos/RegisterRequest';\nimport { SetStatoRegistrazioneDto } from '../Dtos/SetStatoRegistrazione';\nimport { SetUserPasswordRequest } from '../Dtos/SetUserPasswordRequest';\nimport { UserDto } from '../Dtos/UserDto';\nimport { AuthService } from '../Services/AuthService/AuthService';\nimport { EmailService } from '../Services/EmailService/EmailService';\nimport { UserService } from '../Services/UserService/UserService';\nimport { JwtSimpleGuard } from '../jwt/jwt.strategy';\nimport {\n checkPublicAuthRateLimit,\n sendPublicAuthRateLimitExceeded,\n} from '../security/publicAuthRateLimit';\nimport {\n ensureAdmin,\n ensureCanManageTargetUser,\n ensurePrivilegeFlagChanges,\n ensureSelfOrSuperUser,\n ensureUserManagement,\n getAuthenticatedAccessiUser,\n hasPrivilegedUserChanges,\n} from '../security/accessControl';\nimport type { AuthenticatedAccessiUser } from '../security/accessControl';\nimport { assertEmailConfigured } from '../security/emailConfiguration';\nimport { StatoRegistrazione } from '../Dtos/StatoRegistrazione';\n\n@ApiTags('User')\n@Controller('accessi/user')\n/**\n * Gestione utenti: la registrazione pubblica e opt-in, mentre creazione, stato e profili privilegiati\n * richiedono un superutente Accessi. Le API restituiscono sempre il wrapper `BaseResponse` storico.\n */\nexport class UserController {\n private readonly logger = new Logger(UserController.name);\n\n constructor(\n @Inject('ACCESSI_OPTIONS') private readonly accessiOptions: AccessiOptions,\n private readonly userService: UserService,\n private readonly emailService: EmailService,\n private readonly authService: AuthService,\n ) {}\n\n private sendControllerError(res: Response, error: unknown) {\n // Lo status viene derivato centralmente da RestUtilities (HttpException o 500).\n return RestUtilities.sendErrorMessage(res, error, UserController.name);\n }\n\n /**\n * Verifica che il target esista e che l'attore possa gestirlo (rango attore >=\n * rango target: ADMIN > SUPER > utente). Restituisce lo snapshot corrente del\n * target, così i chiamanti possono controllare se e' admin.\n */\n private async ensureManageableTarget(\n actor: AuthenticatedAccessiUser,\n codiceUtente: number,\n ) {\n const target = await this.userService.getAuthenticatedUserSnapshot(codiceUtente);\n if (!target) {\n throw new NotFoundException(`Nessun utente con codice ${codiceUtente}.`);\n }\n ensureCanManageTargetUser(actor, target);\n return target;\n }\n\n @ApiOperation({\n summary: 'Serve la pagina di reset password',\n operationId: 'serveResetPasswordPageUser',\n })\n @ApiParam({\n name: 'token',\n description: 'Token per il reset della password',\n required: true,\n })\n @Get('reset-password/:token')\n async serveResetPasswordPage(@Res() res: Response, @Param('token') _token: string) {\n return res.sendFile(join(__dirname, '..', 'Views', 'reset-password.html'));\n }\n\n @ApiOperation({\n summary: 'Recupera la lista degli utenti',\n operationId: 'getUsers',\n })\n @ApiResponse({\n status: 200,\n description: 'Lista utenti recuperata con successo',\n type: GetUsersResponse,\n })\n @ApiResponse({ status: 401, description: 'Credenziali non valide', type: ErrorResponse })\n @ApiResponse({ status: 403, description: 'Operazione non autorizzata', type: ErrorResponse })\n @ApiResponse({ status: 500, description: 'Errore interno del server', type: ErrorResponse })\n @ApiQuery({\n name: 'email',\n required: false,\n description: \"Email dell'utente da cercare\",\n type: String,\n })\n @ApiQuery({\n name: 'codiceUtente',\n required: false,\n description: \"Codice dell'utente da cercare\",\n type: Number,\n })\n @ApiQuery({\n name: 'includeExtensionFields',\n required: false,\n description: 'Includi extension fields',\n type: Boolean,\n })\n @ApiQuery({\n name: 'includeGrants',\n required: false,\n description: 'Includi permessi',\n type: Boolean,\n })\n @ApiQuery({\n name: 'limit',\n required: false,\n description: 'Numero massimo di utenti restituiti (1-1000). Omesso = tutti.',\n type: Number,\n })\n @ApiQuery({\n name: 'offset',\n required: false,\n description: 'Numero di utenti da saltare (paginazione).',\n type: Number,\n })\n @ApiBearerAuth()\n @UseGuards(JwtSimpleGuard)\n @Get('get-users')\n async getUsers(\n @Req() request: Request,\n @Res() res: Response,\n @Query('email') email?: string,\n @Query('codiceUtente', new ParseIntPipe({ optional: true })) codiceUtente?: number,\n @Query('includeExtensionFields', new ParseBoolPipe({ optional: true }))\n includeExtensionFields?: boolean,\n @Query('includeGrants', new ParseBoolPipe({ optional: true }))\n includeGrants?: boolean,\n @Query('limit', new ParseIntPipe({ optional: true })) limit?: number,\n @Query('offset', new ParseIntPipe({ optional: true })) offset?: number,\n ) {\n try {\n ensureUserManagement(\n getAuthenticatedAccessiUser(request),\n 'Solo gli amministratori possono consultare gli utenti.',\n );\n\n const filters = { email, codiceUtente, limit, offset };\n const options = {\n includeExtensionFields: includeExtensionFields ?? true,\n includeGrants: includeGrants ?? true,\n };\n\n const users = await this.userService.getUsers(filters, options);\n const total = await this.userService.countUsers({ email, codiceUtente });\n res.setHeader('X-Total-Count', String(total));\n return RestUtilities.sendBaseResponse(res, users);\n } catch (error) {\n this.logger.error('Errore durante il recupero degli utenti: ', error);\n return this.sendControllerError(res, error);\n }\n }\n\n @ApiOperation({\n summary: 'Elimina un utente',\n operationId: 'deleteUser',\n description: 'Imposta lo stato di un utente a eliminato senza rimuovere i record.',\n })\n @ApiParam({\n name: 'codiceUtente',\n description: \"Codice identificativo dell'utente da eliminare\",\n required: true,\n example: 123,\n })\n @ApiResponse({ status: 200, description: 'Utente eliminato con successo', type: ActionResponse })\n @ApiResponse({\n status: 400,\n description: 'Errore nei parametri della richiesta',\n type: ErrorResponse,\n })\n @ApiResponse({ status: 500, description: 'Errore interno del server', type: ErrorResponse })\n @ApiBearerAuth()\n @UseGuards(JwtSimpleGuard)\n @Delete('delete-user/:codiceUtente')\n async deleteUser(\n @Req() request: Request,\n @Param('codiceUtente', ParseIntPipe) codiceUtente: number,\n @Res() res: Response,\n ) {\n try {\n const authenticatedUser = getAuthenticatedAccessiUser(request);\n ensureUserManagement(\n authenticatedUser,\n 'Solo gli amministratori possono eliminare utenti.',\n );\n\n const target = await this.ensureManageableTarget(authenticatedUser, codiceUtente);\n if (target.flagAdmin) {\n await this.userService.assertNotLastActiveAdmin(codiceUtente);\n }\n\n await this.userService.deleteUser(codiceUtente);\n return RestUtilities.sendOKMessage(res, \"L'utente e' stato eliminato con successo.\");\n } catch (error) {\n return this.sendControllerError(res, error);\n }\n }\n\n @ApiOperation({\n summary: 'Elimina definitivamente un utente',\n operationId: 'deleteUserPermanently',\n description: 'Rimuove l utente e tutti i record collegati. Operazione distruttiva riservata agli admin.',\n })\n @ApiParam({\n name: 'codiceUtente',\n description: \"Codice identificativo dell'utente da eliminare definitivamente\",\n required: true,\n example: 123,\n })\n @ApiResponse({ status: 200, description: 'Utente eliminato definitivamente', type: ActionResponse })\n @ApiResponse({ status: 400, description: 'Errore nei parametri della richiesta', type: ErrorResponse })\n @ApiResponse({ status: 403, description: 'Operazione non autorizzata', type: ErrorResponse })\n @ApiResponse({ status: 404, description: 'Utente non trovato', type: ErrorResponse })\n @ApiResponse({ status: 500, description: 'Errore interno del server', type: ErrorResponse })\n @ApiBearerAuth()\n @UseGuards(JwtSimpleGuard)\n @Delete('delete-user-permanent/:codiceUtente')\n async deleteUserPermanently(\n @Req() request: Request,\n @Param('codiceUtente', ParseIntPipe) codiceUtente: number,\n @Res() res: Response,\n ) {\n try {\n const authenticatedUser = getAuthenticatedAccessiUser(request);\n ensureAdmin(\n authenticatedUser,\n 'Solo gli admin possono eliminare definitivamente un utente.',\n );\n\n if (authenticatedUser.codiceUtente === codiceUtente) {\n throw new BadRequestException('Non puoi eliminare definitivamente il tuo stesso utente.');\n }\n\n const target = await this.ensureManageableTarget(authenticatedUser, codiceUtente);\n if (target.flagAdmin) {\n await this.userService.assertNotLastActiveAdmin(codiceUtente);\n }\n\n await this.userService.deleteUserPermanently(codiceUtente);\n return RestUtilities.sendOKMessage(res, \"L'utente e' stato eliminato definitivamente.\");\n } catch (error) {\n return this.sendControllerError(res, error);\n }\n }\n\n @ApiOperation({\n summary: 'Forza l invio dell email di reset password a un utente',\n operationId: 'forcePasswordReset',\n description: 'Riservato al superutente. Richiede un servizio email configurato; altrimenti risponde con ACCESSI_EMAIL_NOT_CONFIGURED.',\n })\n @ApiParam({ name: 'codiceUtente', description: 'Codice identificativo dell utente', required: true, example: 123, type: Number })\n @ApiResponse({ status: 200, description: 'Email di reset inviata', type: ActionResponse })\n @ApiResponse({ status: 400, description: 'Servizio email non configurato', type: ErrorResponse })\n @ApiResponse({ status: 404, description: 'Utente non trovato', type: ErrorResponse })\n @ApiBearerAuth()\n @UseGuards(JwtSimpleGuard)\n @Post('force-password-reset/:codiceUtente')\n async forcePasswordReset(\n @Req() request: Request,\n @Param('codiceUtente', ParseIntPipe) codiceUtente: number,\n @Res() res: Response,\n ) {\n try {\n const authenticatedUser = getAuthenticatedAccessiUser(request);\n ensureUserManagement(\n authenticatedUser,\n 'Solo gli amministratori possono forzare il reset password.',\n );\n await this.ensureManageableTarget(authenticatedUser, codiceUtente);\n await this.userService.forcePasswordReset(codiceUtente);\n return RestUtilities.sendOKMessage(res, `Email di reset inviata all utente ${codiceUtente}.`);\n } catch (error) {\n return this.sendControllerError(res, error);\n }\n }\n\n @ApiOperation({\n summary: 'Forza il reset password per tutti gli utenti con password legacy',\n operationId: 'forcePasswordResetLegacy',\n description: 'Riservato al superutente. Invia l email di reset a tutti gli utenti la cui password non e ancora nel formato moderno. Richiede un servizio email configurato.',\n })\n @ApiResponse({ status: 200, description: 'Email di reset inviate', type: ActionResponse })\n @ApiResponse({ status: 400, description: 'Servizio email non configurato', type: ErrorResponse })\n @ApiBearerAuth()\n @UseGuards(JwtSimpleGuard)\n @Post('force-password-reset-legacy')\n async forcePasswordResetLegacy(@Req() request: Request, @Res() res: Response) {\n try {\n ensureUserManagement(\n getAuthenticatedAccessiUser(request),\n 'Solo gli amministratori possono forzare il reset password.',\n );\n const sent = await this.userService.forcePasswordResetForLegacyPasswords();\n return RestUtilities.sendOKMessage(res, `Email di reset inviata a ${sent} utenti con password legacy.`);\n } catch (error) {\n return this.sendControllerError(res, error);\n }\n }\n\n @ApiOperation({\n summary: 'Imposta direttamente la password di un utente',\n operationId: 'setUserPassword',\n description: 'Riservato agli amministratori. Hasha la password, aggiorna la scadenza secondo la policy e non invia email.',\n })\n @ApiParam({ name: 'codiceUtente', description: 'Codice identificativo dell utente', required: true, example: 123, type: Number })\n @ApiBody({ type: SetUserPasswordRequest })\n @ApiResponse({ status: 200, description: 'Password aggiornata', type: ActionResponse })\n @ApiResponse({ status: 400, description: 'Password non valida', type: ErrorResponse })\n @ApiResponse({ status: 403, description: 'Operazione non autorizzata', type: ErrorResponse })\n @ApiBearerAuth()\n @UseGuards(JwtSimpleGuard)\n @Post('set-password/:codiceUtente')\n async setUserPassword(\n @Req() request: Request,\n @Param('codiceUtente', ParseIntPipe) codiceUtente: number,\n @Body() body: SetUserPasswordRequest,\n @Res() res: Response,\n ) {\n try {\n const authenticatedUser = getAuthenticatedAccessiUser(request);\n ensureUserManagement(\n authenticatedUser,\n 'Solo gli amministratori possono impostare la password di un utente.',\n );\n await this.ensureManageableTarget(authenticatedUser, codiceUtente);\n\n await this.authService.setPassword(codiceUtente, body.newPassword);\n return RestUtilities.sendOKMessage(res, `Password dell utente ${codiceUtente} aggiornata.`);\n } catch (error) {\n return this.sendControllerError(res, error);\n }\n }\n\n @ApiOperation({\n summary: 'Imposta lo stato di registrazione di un utente',\n operationId: 'setStatoRegistrazione',\n })\n @ApiResponse({\n status: 200,\n description: 'Stato registrazione aggiornato con successo',\n type: ActionResponse,\n })\n @ApiResponse({\n status: 400,\n description: 'Errore nei parametri della richiesta',\n type: ErrorResponse,\n })\n @ApiResponse({\n status: 500,\n description: 'Errore interno del server',\n type: ErrorResponse,\n })\n @ApiBody({ type: SetStatoRegistrazioneDto })\n @ApiBearerAuth()\n @UseGuards(JwtSimpleGuard)\n @Post('set-stato')\n async setStatoRegistrazione(\n @Req() request: Request,\n @Body() body: SetStatoRegistrazioneDto,\n @Res() res: Response,\n ) {\n try {\n const authenticatedUser = getAuthenticatedAccessiUser(request);\n ensureUserManagement(\n authenticatedUser,\n 'Solo gli amministratori possono modificare lo stato di registrazione.',\n );\n\n const { codiceUtente, statoRegistrazione } = body;\n if (!codiceUtente) throw new BadRequestException('Il codice utente e\\' obbligatorio.');\n if (statoRegistrazione === undefined) {\n throw new BadRequestException('Lo stato registrazione e\\' obbligatorio.');\n }\n\n const target = await this.ensureManageableTarget(authenticatedUser, codiceUtente);\n const disabling = statoRegistrazione === StatoRegistrazione.DELETE\n || statoRegistrazione === StatoRegistrazione.BLOCC;\n if (target.flagAdmin && disabling) {\n await this.userService.assertNotLastActiveAdmin(codiceUtente);\n }\n\n await this.userService.setStato(codiceUtente, statoRegistrazione);\n return RestUtilities.sendOKMessage(\n res,\n `Lo stato dell'utente ${codiceUtente} e' stato aggiornato a ${statoRegistrazione}.`,\n );\n } catch (error) {\n return this.sendControllerError(res, error);\n }\n }\n\n @ApiOperation({\n summary: 'Registra un nuovo utente',\n description: 'Disponibile soltanto quando publicRegistration.enabled e true. Per utenti SSO usare il provisioning master nel tag Federated authentication.',\n operationId: 'register',\n })\n @ApiBody({\n type: PublicRegisterRequest,\n description: \"Dati necessari per la registrazione dell'utente\",\n })\n @ApiCreatedResponse({\n description:\n 'Utente registrato con successo. Restituisce il codice utente e invia una mail di reset password.',\n type: RegisterResponse,\n })\n @ApiResponse({\n status: HttpStatus.BAD_REQUEST,\n description: 'Errore nella registrazione.',\n type: ErrorResponse,\n })\n @ApiResponse({\n status: HttpStatus.INTERNAL_SERVER_ERROR,\n description: 'Errore interno del server durante la registrazione o l\\'invio email.',\n type: ErrorResponse,\n })\n @Post('register')\n async register(\n @Req() request: Request,\n @Body() registrationData: PublicRegisterRequest,\n @Res() res: Response,\n ) {\n try {\n if (this.accessiOptions.publicRegistration?.enabled !== true) {\n throw new HttpException(\n 'La registrazione pubblica e disabilitata. Un amministratore deve creare l utente.',\n HttpStatus.FORBIDDEN,\n );\n }\n\n const rateLimitDecision = checkPublicAuthRateLimit(\n this.accessiOptions,\n 'register',\n request,\n [registrationData?.email],\n );\n if (!rateLimitDecision.allowed) {\n return sendPublicAuthRateLimitExceeded(res, rateLimitDecision.retryAfterSeconds);\n }\n\n assertEmailConfigured(this.accessiOptions);\n\n const codiceUtente = await this.userService.register(registrationData, {\n allowPrivilegedFields: false,\n });\n\n try {\n await this.emailService.sendPasswordResetEmail(registrationData.email);\n } catch (emailError) {\n try {\n await this.userService.deleteUserPermanently(codiceUtente);\n } catch (rollbackError) {\n this.logger.error(`Rollback registrazione utente ${codiceUtente} non riuscita: ${rollbackError instanceof Error ? rollbackError.message : String(rollbackError)}`);\n }\n throw new BadRequestException({\n code: 'ACCESSI_USER_INVITE_EMAIL_FAILED',\n message: `Registrazione non completata: invio email non riuscito (${emailError instanceof Error ? emailError.message : String(emailError)}). Riprova piu tardi.`,\n });\n }\n return RestUtilities.sendBaseResponse(res, codiceUtente, HttpStatus.CREATED);\n } catch (error) {\n const status =\n error instanceof HttpException ? error.getStatus() : HttpStatus.BAD_REQUEST;\n return RestUtilities.sendErrorMessage(res, error, UserController.name, status);\n }\n }\n\n @ApiOperation({ summary: 'Crea un utente locale da amministrazione', operationId: 'createManagedUser', description: 'Riservato a superutente. Crea un utente in attesa di impostazione password e invia la mail di reset.' })\n @ApiBody({ type: RegisterRequest })\n @ApiCreatedResponse({ type: RegisterResponse })\n @ApiBearerAuth()\n @UseGuards(JwtSimpleGuard)\n @Post('create-managed-user')\n async createManagedUser(@Req() request: Request, @Body() registrationData: RegisterRequest, @Res() res: Response) {\n try {\n const authenticatedUser = getAuthenticatedAccessiUser(request);\n ensureUserManagement(authenticatedUser, 'Solo gli amministratori possono creare utenti.');\n ensurePrivilegeFlagChanges(authenticatedUser, registrationData);\n\n // Fail-fast prima di scrivere: senza SMTP non si crea un utente orfano.\n assertEmailConfigured(this.accessiOptions);\n\n const codiceUtente = await this.userService.register(registrationData, { allowPrivilegedFields: true });\n try {\n await this.emailService.sendPasswordResetEmail(registrationData.email, registrationData.htmlMail);\n } catch (emailError) {\n // L'invio e' esterno: se fallisce annulliamo la creazione per non lasciare un utente\n // senza password e senza email di invito (rollback best-effort).\n try {\n await this.userService.deleteUserPermanently(codiceUtente);\n } catch (rollbackError) {\n this.logger.error(`Rollback creazione utente ${codiceUtente} non riuscita: ${rollbackError instanceof Error ? rollbackError.message : String(rollbackError)}`);\n }\n throw new BadRequestException({\n code: 'ACCESSI_USER_INVITE_EMAIL_FAILED',\n message: `Utente non creato: invio email di invito non riuscito (${emailError instanceof Error ? emailError.message : String(emailError)}). Riprova oppure crea l utente e imposta la password manualmente.`,\n });\n }\n return RestUtilities.sendBaseResponse(res, codiceUtente, HttpStatus.CREATED);\n } catch (error) {\n return this.sendControllerError(res, error);\n }\n }\n\n @ApiOperation({\n summary: 'Aggiorna un utente esistente',\n operationId: 'updateUtente',\n })\n @ApiParam({\n name: 'codiceUtente',\n description: \"Codice identificativo dell'utente da aggiornare\",\n required: true,\n example: 123,\n })\n @ApiBody({\n type: UserDto,\n description: \"Dati aggiornati dell'utente\",\n })\n @ApiResponse({\n status: HttpStatus.OK,\n description: 'Utente aggiornato con successo',\n type: ActionResponse,\n })\n @ApiResponse({ status: 400, description: \"Errore nell'aggiornamento\", type: ErrorResponse })\n @ApiResponse({ status: 403, description: 'Operazione non autorizzata', type: ErrorResponse })\n @ApiResponse({ status: 500, description: 'Errore interno del server', type: ErrorResponse })\n @ApiBearerAuth()\n @UseGuards(JwtSimpleGuard)\n @Put('update-user/:codiceUtente')\n async updateUtente(\n @Req() request: Request,\n @Param('codiceUtente', ParseIntPipe) codiceUtente: number,\n @Body() user: UserDto,\n @Res() res: Response,\n ) {\n try {\n const authenticatedUser = getAuthenticatedAccessiUser(request);\n const isPrivilegedUpdate = hasPrivilegedUserChanges(user);\n const isSelf = authenticatedUser.codiceUtente === codiceUtente;\n\n // ADMIN > SUPER: un superutente non puo' toccare un admin. Self sempre consentito.\n if (!isSelf) {\n await this.ensureManageableTarget(authenticatedUser, codiceUtente);\n }\n\n if (isPrivilegedUpdate) {\n ensureUserManagement(\n authenticatedUser,\n 'Solo gli amministratori possono modificare ruoli, permessi o flag privilegiati.',\n );\n ensurePrivilegeFlagChanges(authenticatedUser, user);\n if (user.flagAdmin === false) {\n await this.userService.assertNotLastActiveAdmin(codiceUtente);\n }\n } else {\n ensureSelfOrSuperUser(\n authenticatedUser,\n codiceUtente,\n 'Puoi modificare solo il tuo profilo.',\n );\n }\n\n if (user.codiceUtente !== undefined && user.codiceUtente !== codiceUtente) {\n throw new BadRequestException('Il codice utente nel body non coincide con quello del path.');\n }\n\n await this.userService.updateUser(codiceUtente, user, {\n allowPrivilegedChanges: authenticatedUser.flagSuper || authenticatedUser.flagAdmin,\n });\n\n return RestUtilities.sendOKMessage(\n res,\n `L'utente ${codiceUtente} e' stato aggiornato con successo.`,\n );\n } catch (error) {\n return this.sendControllerError(res, error);\n }\n }\n\n @ApiOperation({\n summary: 'Imposta il consenso GDPR per un utente',\n operationId: 'setGdpr',\n })\n @ApiParam({\n name: 'codiceUtente',\n description: \"Codice identificativo dell'utente che accetta il GDPR\",\n required: true,\n example: 123,\n })\n @ApiResponse({\n status: 200,\n description: 'Consenso GDPR impostato con successo',\n type: ActionResponse,\n })\n @ApiResponse({ status: 400, description: 'Errore nella richiesta', type: ErrorResponse })\n @ApiResponse({ status: 403, description: 'Operazione non autorizzata', type: ErrorResponse })\n @ApiBearerAuth()\n @UseGuards(JwtSimpleGuard)\n @Patch('set-gdpr/:codiceUtente')\n async setGdpr(\n @Req() request: Request,\n @Param('codiceUtente', ParseIntPipe) codiceUtente: number,\n @Res() res: Response,\n ) {\n try {\n const authenticatedUser = getAuthenticatedAccessiUser(request);\n ensureSelfOrSuperUser(\n authenticatedUser,\n codiceUtente,\n 'Puoi impostare il GDPR solo sul tuo utente.',\n );\n if (authenticatedUser.codiceUtente !== codiceUtente) {\n await this.ensureManageableTarget(authenticatedUser, codiceUtente);\n }\n\n await this.userService.setGdpr(codiceUtente);\n return RestUtilities.sendOKMessage(res, `L'utente ${codiceUtente} ha accettato il GDPR.`);\n } catch (error) {\n return this.sendControllerError(res, error);\n }\n }\n}\n"]}
|
|
@@ -17,7 +17,7 @@ class ConfirmResetPasswordRequest {
|
|
|
17
17
|
exports.ConfirmResetPasswordRequest = ConfirmResetPasswordRequest;
|
|
18
18
|
__decorate([
|
|
19
19
|
(0, swagger_1.ApiProperty)({
|
|
20
|
-
description: 'Nuova password
|
|
20
|
+
description: 'Nuova password: almeno 8 caratteri con maiuscola, minuscola, cifra e carattere speciale, senza spazi e non comune. Se non conforme l API risponde 400 con codice ACCESSI_WEAK_PASSWORD.',
|
|
21
21
|
minLength: 8,
|
|
22
22
|
maxLength: 100,
|
|
23
23
|
example: 'PasswordSicura123!',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfirmResetPasswordRequest.js","sourceRoot":"","sources":["../../../src/accessi-module/Dtos/ConfirmResetPasswordRequest.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAA8C;AAC9C,qDAAmD;AAEnD,MAAa,2BAA2B;CAYvC;AAZD,kEAYC;AADC;IAVC,IAAA,qBAAW,EAAC;QACX,WAAW,EAAE,
|
|
1
|
+
{"version":3,"file":"ConfirmResetPasswordRequest.js","sourceRoot":"","sources":["../../../src/accessi-module/Dtos/ConfirmResetPasswordRequest.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAA8C;AAC9C,qDAAmD;AAEnD,MAAa,2BAA2B;CAYvC;AAZD,kEAYC;AADC;IAVC,IAAA,qBAAW,EAAC;QACX,WAAW,EAAE,yLAAyL;QACtM,SAAS,EAAE,CAAC;QACZ,SAAS,EAAE,GAAG;QACd,OAAO,EAAE,oBAAoB;KAC9B,CAAC;IACD,IAAA,0BAAQ,EAAC,EAAE,OAAO,EAAE,4CAA4C,EAAE,CAAC;IACnE,IAAA,wBAAM,EAAC,CAAC,EAAE,GAAG,EAAE;QACd,OAAO,EAAE,+DAA+D;KACzE,CAAC;;gEACmB","sourcesContent":["import { ApiProperty } from '@nestjs/swagger';\nimport { IsString, Length } from 'class-validator';\n\nexport class ConfirmResetPasswordRequest {\n @ApiProperty({\n description: 'Nuova password: almeno 8 caratteri con maiuscola, minuscola, cifra e carattere speciale, senza spazi e non comune. Se non conforme l API risponde 400 con codice ACCESSI_WEAK_PASSWORD.',\n minLength: 8,\n maxLength: 100,\n example: 'PasswordSicura123!',\n })\n @IsString({ message: 'La nuova password deve essere una stringa.' })\n @Length(8, 100, {\n message: 'La nuova password deve essere compresa tra 8 e 100 caratteri.',\n })\n newPassword!: string;\n}\n"]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { BaseResponse } from './BaseResponse';
|
|
2
|
+
/** Esito dell'emissione di un ticket di ingresso alla console. */
|
|
3
|
+
export declare class ConsoleEntryTicketResult {
|
|
4
|
+
ticket: string;
|
|
5
|
+
expiresInSeconds: number;
|
|
6
|
+
}
|
|
7
|
+
export declare class ConsoleEntryTicketResponse extends BaseResponse {
|
|
8
|
+
Result: ConsoleEntryTicketResult;
|
|
9
|
+
}
|
|
10
|
+
/** Body dello scambio del ticket. */
|
|
11
|
+
export declare class ConsoleEntryExchangeRequest {
|
|
12
|
+
ticket: string;
|
|
13
|
+
}
|
|
14
|
+
/** Sessione Accessi restituita dallo scambio, da usare come Bearer nella console. */
|
|
15
|
+
export declare class ConsoleEntryTokenResult {
|
|
16
|
+
value: string;
|
|
17
|
+
type: string;
|
|
18
|
+
}
|
|
19
|
+
export declare class ConsoleEntrySessionResult {
|
|
20
|
+
token: ConsoleEntryTokenResult;
|
|
21
|
+
}
|
|
22
|
+
export declare class ConsoleEntrySessionResponse extends BaseResponse {
|
|
23
|
+
Result: ConsoleEntrySessionResult;
|
|
24
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
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.ConsoleEntrySessionResponse = exports.ConsoleEntrySessionResult = exports.ConsoleEntryTokenResult = exports.ConsoleEntryExchangeRequest = exports.ConsoleEntryTicketResponse = exports.ConsoleEntryTicketResult = void 0;
|
|
13
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
14
|
+
const class_validator_1 = require("class-validator");
|
|
15
|
+
const BaseResponse_1 = require("./BaseResponse");
|
|
16
|
+
/** Esito dell'emissione di un ticket di ingresso alla console. */
|
|
17
|
+
class ConsoleEntryTicketResult {
|
|
18
|
+
}
|
|
19
|
+
exports.ConsoleEntryTicketResult = ConsoleEntryTicketResult;
|
|
20
|
+
__decorate([
|
|
21
|
+
(0, swagger_1.ApiProperty)({
|
|
22
|
+
description: 'Ticket monouso da usare in /api/accessi/console#entry=<ticket>.',
|
|
23
|
+
example: 'f'.repeat(64),
|
|
24
|
+
}),
|
|
25
|
+
__metadata("design:type", String)
|
|
26
|
+
], ConsoleEntryTicketResult.prototype, "ticket", void 0);
|
|
27
|
+
__decorate([
|
|
28
|
+
(0, swagger_1.ApiProperty)({ description: 'Validita del ticket in secondi.', example: 60 }),
|
|
29
|
+
__metadata("design:type", Number)
|
|
30
|
+
], ConsoleEntryTicketResult.prototype, "expiresInSeconds", void 0);
|
|
31
|
+
class ConsoleEntryTicketResponse extends BaseResponse_1.BaseResponse {
|
|
32
|
+
}
|
|
33
|
+
exports.ConsoleEntryTicketResponse = ConsoleEntryTicketResponse;
|
|
34
|
+
__decorate([
|
|
35
|
+
(0, swagger_1.ApiProperty)({ type: ConsoleEntryTicketResult }),
|
|
36
|
+
__metadata("design:type", ConsoleEntryTicketResult)
|
|
37
|
+
], ConsoleEntryTicketResponse.prototype, "Result", void 0);
|
|
38
|
+
/** Body dello scambio del ticket. */
|
|
39
|
+
class ConsoleEntryExchangeRequest {
|
|
40
|
+
}
|
|
41
|
+
exports.ConsoleEntryExchangeRequest = ConsoleEntryExchangeRequest;
|
|
42
|
+
__decorate([
|
|
43
|
+
(0, swagger_1.ApiProperty)({
|
|
44
|
+
description: 'Ticket monouso restituito da POST /api/accessi/console/entry.',
|
|
45
|
+
example: 'f'.repeat(64),
|
|
46
|
+
}),
|
|
47
|
+
(0, class_validator_1.IsString)({ message: 'Il ticket deve essere una stringa.' }),
|
|
48
|
+
(0, class_validator_1.Length)(64, 64, { message: 'Il ticket deve essere lungo 64 caratteri.' }),
|
|
49
|
+
__metadata("design:type", String)
|
|
50
|
+
], ConsoleEntryExchangeRequest.prototype, "ticket", void 0);
|
|
51
|
+
/** Sessione Accessi restituita dallo scambio, da usare come Bearer nella console. */
|
|
52
|
+
class ConsoleEntryTokenResult {
|
|
53
|
+
}
|
|
54
|
+
exports.ConsoleEntryTokenResult = ConsoleEntryTokenResult;
|
|
55
|
+
__decorate([
|
|
56
|
+
(0, swagger_1.ApiProperty)({ description: 'JWT Accessi.', example: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...' }),
|
|
57
|
+
__metadata("design:type", String)
|
|
58
|
+
], ConsoleEntryTokenResult.prototype, "value", void 0);
|
|
59
|
+
__decorate([
|
|
60
|
+
(0, swagger_1.ApiProperty)({ description: 'Schema di autorizzazione.', example: 'Bearer' }),
|
|
61
|
+
__metadata("design:type", String)
|
|
62
|
+
], ConsoleEntryTokenResult.prototype, "type", void 0);
|
|
63
|
+
class ConsoleEntrySessionResult {
|
|
64
|
+
}
|
|
65
|
+
exports.ConsoleEntrySessionResult = ConsoleEntrySessionResult;
|
|
66
|
+
__decorate([
|
|
67
|
+
(0, swagger_1.ApiProperty)({ type: ConsoleEntryTokenResult }),
|
|
68
|
+
__metadata("design:type", ConsoleEntryTokenResult)
|
|
69
|
+
], ConsoleEntrySessionResult.prototype, "token", void 0);
|
|
70
|
+
class ConsoleEntrySessionResponse extends BaseResponse_1.BaseResponse {
|
|
71
|
+
}
|
|
72
|
+
exports.ConsoleEntrySessionResponse = ConsoleEntrySessionResponse;
|
|
73
|
+
__decorate([
|
|
74
|
+
(0, swagger_1.ApiProperty)({ type: ConsoleEntrySessionResult }),
|
|
75
|
+
__metadata("design:type", ConsoleEntrySessionResult)
|
|
76
|
+
], ConsoleEntrySessionResponse.prototype, "Result", void 0);
|
|
77
|
+
//# sourceMappingURL=ConsoleEntryDtos.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ConsoleEntryDtos.js","sourceRoot":"","sources":["../../../src/accessi-module/Dtos/ConsoleEntryDtos.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAA8C;AAC9C,qDAAmD;AACnD,iDAA8C;AAE9C,kEAAkE;AAClE,MAAa,wBAAwB;CASpC;AATD,4DASC;AAJC;IAJC,IAAA,qBAAW,EAAC;QACX,WAAW,EAAE,iEAAiE;QAC9E,OAAO,EAAE,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC;KACxB,CAAC;;wDACc;AAGhB;IADC,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,iCAAiC,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;;kEACnD;AAG5B,MAAa,0BAA2B,SAAQ,2BAAY;CAG3D;AAHD,gEAGC;AADC;IADC,IAAA,qBAAW,EAAC,EAAE,IAAI,EAAE,wBAAwB,EAAE,CAAC;8BACvC,wBAAwB;0DAAC;AAGpC,qCAAqC;AACrC,MAAa,2BAA2B;CAQvC;AARD,kEAQC;AADC;IANC,IAAA,qBAAW,EAAC;QACX,WAAW,EAAE,+DAA+D;QAC5E,OAAO,EAAE,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC;KACxB,CAAC;IACD,IAAA,0BAAQ,EAAC,EAAE,OAAO,EAAE,oCAAoC,EAAE,CAAC;IAC3D,IAAA,wBAAM,EAAC,EAAE,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE,2CAA2C,EAAE,CAAC;;2DACzD;AAGlB,qFAAqF;AACrF,MAAa,uBAAuB;CAMnC;AAND,0DAMC;AAJC;IADC,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,cAAc,EAAE,OAAO,EAAE,yCAAyC,EAAE,CAAC;;sDAClF;AAGf;IADC,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,2BAA2B,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC;;qDAC/D;AAGhB,MAAa,yBAAyB;CAGrC;AAHD,8DAGC;AADC;IADC,IAAA,qBAAW,EAAC,EAAE,IAAI,EAAE,uBAAuB,EAAE,CAAC;8BACvC,uBAAuB;wDAAC;AAGlC,MAAa,2BAA4B,SAAQ,2BAAY;CAG5D;AAHD,kEAGC;AADC;IADC,IAAA,qBAAW,EAAC,EAAE,IAAI,EAAE,yBAAyB,EAAE,CAAC;8BACxC,yBAAyB;2DAAC","sourcesContent":["import { ApiProperty } from '@nestjs/swagger';\nimport { IsString, Length } from 'class-validator';\nimport { BaseResponse } from './BaseResponse';\n\n/** Esito dell'emissione di un ticket di ingresso alla console. */\nexport class ConsoleEntryTicketResult {\n @ApiProperty({\n description: 'Ticket monouso da usare in /api/accessi/console#entry=<ticket>.',\n example: 'f'.repeat(64),\n })\n ticket!: string;\n\n @ApiProperty({ description: 'Validita del ticket in secondi.', example: 60 })\n expiresInSeconds!: number;\n}\n\nexport class ConsoleEntryTicketResponse extends BaseResponse {\n @ApiProperty({ type: ConsoleEntryTicketResult })\n Result!: ConsoleEntryTicketResult;\n}\n\n/** Body dello scambio del ticket. */\nexport class ConsoleEntryExchangeRequest {\n @ApiProperty({\n description: 'Ticket monouso restituito da POST /api/accessi/console/entry.',\n example: 'f'.repeat(64),\n })\n @IsString({ message: 'Il ticket deve essere una stringa.' })\n @Length(64, 64, { message: 'Il ticket deve essere lungo 64 caratteri.' })\n ticket!: string;\n}\n\n/** Sessione Accessi restituita dallo scambio, da usare come Bearer nella console. */\nexport class ConsoleEntryTokenResult {\n @ApiProperty({ description: 'JWT Accessi.', example: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...' })\n value!: string;\n\n @ApiProperty({ description: 'Schema di autorizzazione.', example: 'Bearer' })\n type!: string;\n}\n\nexport class ConsoleEntrySessionResult {\n @ApiProperty({ type: ConsoleEntryTokenResult })\n token!: ConsoleEntryTokenResult;\n}\n\nexport class ConsoleEntrySessionResponse extends BaseResponse {\n @ApiProperty({ type: ConsoleEntrySessionResult })\n Result!: ConsoleEntrySessionResult;\n}\n"]}
|