emilsoftware-utilities 1.3.119 → 1.3.121
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.
|
@@ -31,6 +31,7 @@ const EmailService_1 = require("../Services/EmailService/EmailService");
|
|
|
31
31
|
const path_1 = require("path");
|
|
32
32
|
const GetUsersResponse_1 = require("../Dtos/GetUsersResponse");
|
|
33
33
|
const Dtos_1 = require("../Dtos");
|
|
34
|
+
const RegisterResponse_1 = require("../Dtos/RegisterResponse");
|
|
34
35
|
let UserController = UserController_1 = class UserController {
|
|
35
36
|
constructor(userService, emailService, options) {
|
|
36
37
|
this.userService = userService;
|
|
@@ -69,18 +70,18 @@ let UserController = UserController_1 = class UserController {
|
|
|
69
70
|
register(request, registrationData, res) {
|
|
70
71
|
return __awaiter(this, void 0, void 0, function* () {
|
|
71
72
|
try {
|
|
72
|
-
|
|
73
|
-
|
|
73
|
+
const protocol = request['protocol'];
|
|
74
|
+
const host = request.headers['host'];
|
|
74
75
|
if (!protocol || !host) {
|
|
75
76
|
throw new Error("Impossibile procedere: protocollo e host non impostati negli header della richiesta.");
|
|
76
77
|
}
|
|
77
|
-
const
|
|
78
|
-
|
|
78
|
+
const codiceUtente = yield this.userService.register(registrationData);
|
|
79
|
+
const confirmationEmailPrefix = `${protocol}://${host}`;
|
|
79
80
|
yield this.emailService.sendPasswordResetEmail(registrationData.email, confirmationEmailPrefix);
|
|
80
|
-
return Utilities_1.RestUtilities.sendBaseResponse(res,
|
|
81
|
+
return Utilities_1.RestUtilities.sendBaseResponse(res, codiceUtente);
|
|
81
82
|
}
|
|
82
83
|
catch (error) {
|
|
83
|
-
return Utilities_1.RestUtilities.sendErrorMessage(res, error, UserController_1.name);
|
|
84
|
+
return Utilities_1.RestUtilities.sendErrorMessage(res, error, UserController_1.name, common_1.HttpStatus.BAD_REQUEST);
|
|
84
85
|
}
|
|
85
86
|
});
|
|
86
87
|
}
|
|
@@ -151,10 +152,26 @@ __decorate([
|
|
|
151
152
|
__metadata("design:returntype", Promise)
|
|
152
153
|
], UserController.prototype, "deleteUser", null);
|
|
153
154
|
__decorate([
|
|
154
|
-
(0, swagger_1.ApiOperation)({
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
155
|
+
(0, swagger_1.ApiOperation)({
|
|
156
|
+
summary: 'Registra un nuovo utente',
|
|
157
|
+
operationId: 'register',
|
|
158
|
+
}),
|
|
159
|
+
(0, swagger_1.ApiBody)({
|
|
160
|
+
type: Dtos_1.UserDto,
|
|
161
|
+
description: "Dati necessari per la registrazione dell'utente"
|
|
162
|
+
}),
|
|
163
|
+
(0, swagger_1.ApiCreatedResponse)({
|
|
164
|
+
description: 'Utente registrato con successo. Restituisce il codice utente e invia una mail di conferma/reset password.',
|
|
165
|
+
type: RegisterResponse_1.RegisterResponse
|
|
166
|
+
}),
|
|
167
|
+
(0, swagger_1.ApiResponse)({
|
|
168
|
+
status: common_1.HttpStatus.BAD_REQUEST,
|
|
169
|
+
description: 'Errore nella registrazione. Potrebbe essere dovuto a dati mancanti, email già esistente o configurazione non valida.'
|
|
170
|
+
}),
|
|
171
|
+
(0, swagger_1.ApiResponse)({
|
|
172
|
+
status: common_1.HttpStatus.INTERNAL_SERVER_ERROR,
|
|
173
|
+
description: 'Errore interno del server durante la registrazione o l’invio dell’email.'
|
|
174
|
+
}),
|
|
158
175
|
(0, common_1.Post)('register'),
|
|
159
176
|
__param(0, (0, common_1.Req)()),
|
|
160
177
|
__param(1, (0, common_1.Body)()),
|
|
@@ -175,7 +192,7 @@ __decorate([
|
|
|
175
192
|
type: Dtos_1.UserDto,
|
|
176
193
|
description: "Dati aggiornati dell'utente (escluso il codice utente, che è nel path)"
|
|
177
194
|
}),
|
|
178
|
-
(0, swagger_1.ApiResponse)({ status:
|
|
195
|
+
(0, swagger_1.ApiResponse)({ status: common_1.HttpStatus.OK, description: "Utente aggiornato con successo" }),
|
|
179
196
|
(0, swagger_1.ApiResponse)({ status: 400, description: "Errore nell'aggiornamento" }),
|
|
180
197
|
(0, common_1.Put)('update-user/:codiceUtente'),
|
|
181
198
|
__param(0, (0, common_1.Param)('codiceUtente')),
|
|
@@ -0,0 +1,24 @@
|
|
|
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.RegisterResponse = void 0;
|
|
13
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
14
|
+
const BaseResponse_1 = require("./BaseResponse");
|
|
15
|
+
class RegisterResponse extends BaseResponse_1.BaseResponse {
|
|
16
|
+
}
|
|
17
|
+
exports.RegisterResponse = RegisterResponse;
|
|
18
|
+
__decorate([
|
|
19
|
+
(0, swagger_1.ApiProperty)({
|
|
20
|
+
description: 'Codice identificativo univoco dell’utente registrato',
|
|
21
|
+
example: 'USR-123456'
|
|
22
|
+
}),
|
|
23
|
+
__metadata("design:type", String)
|
|
24
|
+
], RegisterResponse.prototype, "Result", void 0);
|
|
@@ -15,7 +15,7 @@ export declare class UserService {
|
|
|
15
15
|
}>;
|
|
16
16
|
getUserByEmail(email: string): Promise<UserDto | null>;
|
|
17
17
|
getUserFilters(codiceUtente: number): Promise<FiltriUtente[]>;
|
|
18
|
-
register(registrationData: UserDto): Promise<
|
|
18
|
+
register(registrationData: UserDto): Promise<string>;
|
|
19
19
|
updateUser(codiceUtente: number, user: UserDto): Promise<void>;
|
|
20
20
|
deleteUser(codiceCliente: number): Promise<void>;
|
|
21
21
|
setGdpr(codiceUtente: number): Promise<any>;
|