emilsoftware-utilities 1.3.126 → 1.3.128
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/Controllers/EmailController.js +1 -7
- package/dist/accessi-module/Controllers/UserController.d.ts +1 -0
- package/dist/accessi-module/Controllers/UserController.js +5 -8
- package/dist/accessi-module/Dtos/GetUsersResponse.d.ts +7 -1
- package/dist/accessi-module/Dtos/GetUsersResponse.js +23 -3
- package/dist/accessi-module/Services/EmailService/EmailService.d.ts +1 -1
- package/dist/accessi-module/Services/EmailService/EmailService.js +3 -2
- package/dist/accessi-module/Services/UserService/UserService.d.ts +2 -2
- package/dist/accessi-module/Services/UserService/UserService.js +18 -2
- package/package.json +1 -1
|
@@ -41,13 +41,7 @@ let EmailController = EmailController_1 = class EmailController {
|
|
|
41
41
|
sendPasswordResetEmail(request, sendResetPasswordData, res) {
|
|
42
42
|
return __awaiter(this, void 0, void 0, function* () {
|
|
43
43
|
try {
|
|
44
|
-
|
|
45
|
-
let host = request.headers["host"];
|
|
46
|
-
if (!protocol || !host) {
|
|
47
|
-
throw new Error("Impossibile procedere: protocollo e host non impostati negli header della richiesta.");
|
|
48
|
-
}
|
|
49
|
-
let confirmationEmailPrefix = `${protocol}://${host}`;
|
|
50
|
-
yield this.emailService.sendPasswordResetEmail(sendResetPasswordData.email, confirmationEmailPrefix);
|
|
44
|
+
yield this.emailService.sendPasswordResetEmail(sendResetPasswordData.email);
|
|
51
45
|
return Utilities_1.RestUtilities.sendOKMessage(res, "L'email di reset è stata inoltrata al destinatario.");
|
|
52
46
|
}
|
|
53
47
|
catch (error) {
|
|
@@ -8,6 +8,7 @@ export declare class UserController {
|
|
|
8
8
|
private readonly userService;
|
|
9
9
|
private readonly emailService;
|
|
10
10
|
private readonly options;
|
|
11
|
+
private readonly logger;
|
|
11
12
|
constructor(userService: UserService, emailService: EmailService, options: AccessiOptions);
|
|
12
13
|
serveResetPasswordPage(res: Response, token: string): Promise<void>;
|
|
13
14
|
getUsers(res: Response): Promise<Response<any, Record<string, any>>>;
|
|
@@ -33,11 +33,13 @@ const GetUsersResponse_1 = require("../Dtos/GetUsersResponse");
|
|
|
33
33
|
const Dtos_1 = require("../Dtos");
|
|
34
34
|
const RegisterResponse_1 = require("../Dtos/RegisterResponse");
|
|
35
35
|
const RegisterRequest_1 = require("../Dtos/RegisterRequest");
|
|
36
|
+
const Logger_1 = require("../../Logger");
|
|
36
37
|
let UserController = UserController_1 = class UserController {
|
|
37
38
|
constructor(userService, emailService, options) {
|
|
38
39
|
this.userService = userService;
|
|
39
40
|
this.emailService = emailService;
|
|
40
41
|
this.options = options;
|
|
42
|
+
this.logger = new Logger_1.Logger(UserController_1.name);
|
|
41
43
|
}
|
|
42
44
|
serveResetPasswordPage(res, token) {
|
|
43
45
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -51,7 +53,8 @@ let UserController = UserController_1 = class UserController {
|
|
|
51
53
|
return Utilities_1.RestUtilities.sendBaseResponse(res, users);
|
|
52
54
|
}
|
|
53
55
|
catch (error) {
|
|
54
|
-
|
|
56
|
+
this.logger.error('Errore durante il recupero degli utenti', error);
|
|
57
|
+
return Utilities_1.RestUtilities.sendErrorMessage(res, error, UserController_1.name);
|
|
55
58
|
}
|
|
56
59
|
});
|
|
57
60
|
}
|
|
@@ -71,14 +74,8 @@ let UserController = UserController_1 = class UserController {
|
|
|
71
74
|
register(request, registrationData, res) {
|
|
72
75
|
return __awaiter(this, void 0, void 0, function* () {
|
|
73
76
|
try {
|
|
74
|
-
const protocol = request['protocol'];
|
|
75
|
-
const host = request.headers['host'];
|
|
76
|
-
if (!protocol || !host) {
|
|
77
|
-
throw new Error("Impossibile procedere: protocollo e host non impostati negli header della richiesta.");
|
|
78
|
-
}
|
|
79
77
|
const codiceUtente = yield this.userService.register(registrationData);
|
|
80
|
-
|
|
81
|
-
yield this.emailService.sendPasswordResetEmail(registrationData.email, confirmationEmailPrefix);
|
|
78
|
+
yield this.emailService.sendPasswordResetEmail(registrationData.email);
|
|
82
79
|
return Utilities_1.RestUtilities.sendBaseResponse(res, codiceUtente);
|
|
83
80
|
}
|
|
84
81
|
catch (error) {
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { BaseResponse } from './BaseResponse';
|
|
2
2
|
import { UserDto } from './UserDto';
|
|
3
|
+
import { UserGrantsDto } from './UserGrantsDto';
|
|
4
|
+
export declare class GetUsersResult {
|
|
5
|
+
utente?: UserDto;
|
|
6
|
+
userGrants?: UserGrantsDto;
|
|
7
|
+
extensionFields?: any;
|
|
8
|
+
}
|
|
3
9
|
export declare class GetUsersResponse extends BaseResponse {
|
|
4
|
-
Result:
|
|
10
|
+
Result: GetUsersResult[];
|
|
5
11
|
}
|
|
@@ -9,18 +9,38 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.GetUsersResponse = void 0;
|
|
12
|
+
exports.GetUsersResponse = exports.GetUsersResult = void 0;
|
|
13
13
|
const swagger_1 = require("@nestjs/swagger");
|
|
14
14
|
const class_validator_1 = require("class-validator");
|
|
15
15
|
const class_transformer_1 = require("class-transformer");
|
|
16
16
|
const BaseResponse_1 = require("./BaseResponse");
|
|
17
17
|
const UserDto_1 = require("./UserDto");
|
|
18
|
+
const UserGrantsDto_1 = require("./UserGrantsDto");
|
|
19
|
+
class GetUsersResult {
|
|
20
|
+
}
|
|
21
|
+
exports.GetUsersResult = GetUsersResult;
|
|
22
|
+
__decorate([
|
|
23
|
+
(0, swagger_1.ApiProperty)({ description: 'Dati utente', type: UserDto_1.UserDto }),
|
|
24
|
+
(0, class_validator_1.ValidateNested)(),
|
|
25
|
+
(0, class_transformer_1.Type)(() => UserDto_1.UserDto),
|
|
26
|
+
__metadata("design:type", UserDto_1.UserDto)
|
|
27
|
+
], GetUsersResult.prototype, "utente", void 0);
|
|
28
|
+
__decorate([
|
|
29
|
+
(0, swagger_1.ApiProperty)({ description: 'Abilitazioni e ruoli utente', type: UserGrantsDto_1.UserGrantsDto }),
|
|
30
|
+
(0, class_validator_1.ValidateNested)(),
|
|
31
|
+
(0, class_transformer_1.Type)(() => UserGrantsDto_1.UserGrantsDto),
|
|
32
|
+
__metadata("design:type", UserGrantsDto_1.UserGrantsDto)
|
|
33
|
+
], GetUsersResult.prototype, "userGrants", void 0);
|
|
34
|
+
__decorate([
|
|
35
|
+
(0, swagger_1.ApiProperty)({ description: 'Extension Fields', type: Object }),
|
|
36
|
+
__metadata("design:type", Object)
|
|
37
|
+
], GetUsersResult.prototype, "extensionFields", void 0);
|
|
18
38
|
class GetUsersResponse extends BaseResponse_1.BaseResponse {
|
|
19
39
|
}
|
|
20
40
|
exports.GetUsersResponse = GetUsersResponse;
|
|
21
41
|
__decorate([
|
|
22
|
-
(0, swagger_1.ApiProperty)({ type: [
|
|
42
|
+
(0, swagger_1.ApiProperty)({ type: [GetUsersResult] }),
|
|
23
43
|
(0, class_validator_1.ValidateNested)({ each: true }),
|
|
24
|
-
(0, class_transformer_1.Type)(() =>
|
|
44
|
+
(0, class_transformer_1.Type)(() => GetUsersResult),
|
|
25
45
|
__metadata("design:type", Array)
|
|
26
46
|
], GetUsersResponse.prototype, "Result", void 0);
|
|
@@ -4,5 +4,5 @@ export declare class EmailService {
|
|
|
4
4
|
constructor(accessiOptions: AccessiOptions);
|
|
5
5
|
sendAccountUpdateEmail(email: string, message: string): Promise<void>;
|
|
6
6
|
private transporter;
|
|
7
|
-
sendPasswordResetEmail(email: string
|
|
7
|
+
sendPasswordResetEmail(email: string): Promise<void>;
|
|
8
8
|
}
|
|
@@ -38,7 +38,7 @@ let EmailService = class EmailService {
|
|
|
38
38
|
sendAccountUpdateEmail(email, message) {
|
|
39
39
|
throw new Error('Method not implemented.');
|
|
40
40
|
}
|
|
41
|
-
sendPasswordResetEmail(email
|
|
41
|
+
sendPasswordResetEmail(email) {
|
|
42
42
|
return __awaiter(this, void 0, void 0, function* () {
|
|
43
43
|
try {
|
|
44
44
|
const resetToken = (0, uuid_1.v4)(); // Generiamo un nuovo token unico
|
|
@@ -48,7 +48,8 @@ let EmailService = class EmailService {
|
|
|
48
48
|
throw new Error("Email non trovata.");
|
|
49
49
|
}
|
|
50
50
|
const returnUrlQueryParams = "?returnUrl=" + this.accessiOptions.confirmationEmailReturnUrl;
|
|
51
|
-
const
|
|
51
|
+
const { confirmationEmailUrl } = this.accessiOptions;
|
|
52
|
+
const resetUrl = `${confirmationEmailUrl}/api/accessi/email/reset-password-page/${resetToken}${returnUrlQueryParams}`;
|
|
52
53
|
const mailOptions = {
|
|
53
54
|
from: this.accessiOptions.emailOptions.from,
|
|
54
55
|
to: email,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AccessiOptions } from "../../AccessiModule";
|
|
2
2
|
import { EmailService } from "../EmailService/EmailService";
|
|
3
3
|
import { FiltriUtente } from "../../Dtos/FiltriUtente";
|
|
4
|
-
import {
|
|
4
|
+
import { GetUsersResult } from "../../Dtos/GetUsersResponse";
|
|
5
5
|
import { PermissionService } from "../PermissionService/PermissionService";
|
|
6
6
|
import { UserDto } from "../../Dtos";
|
|
7
7
|
import { RegisterRequest } from "../../Dtos/RegisterRequest";
|
|
@@ -10,7 +10,7 @@ export declare class UserService {
|
|
|
10
10
|
private readonly emailService;
|
|
11
11
|
private readonly permissionService;
|
|
12
12
|
constructor(accessiOptions: AccessiOptions, emailService: EmailService, permissionService: PermissionService);
|
|
13
|
-
getUsers(): Promise<
|
|
13
|
+
getUsers(): Promise<GetUsersResult[]>;
|
|
14
14
|
getCodiceUtenteByEmail(email: string): Promise<{
|
|
15
15
|
codiceUtente: number;
|
|
16
16
|
}>;
|
|
@@ -60,8 +60,24 @@ let UserService = class UserService {
|
|
|
60
60
|
FROM UTENTI U INNER JOIN UTENTI_CONFIG G ON U.CODUTE = G.CODUTE
|
|
61
61
|
WHERE STAREG <> ?
|
|
62
62
|
ORDER BY U.CODUTE`;
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
let users = yield Orm_1.Orm.query(this.accessiOptions.databaseOptions, query, [StatoRegistrazione_1.StatoRegistrazione.DELETE]);
|
|
64
|
+
users = users.map(Utilities_1.RestUtilities.convertKeysToCamelCase);
|
|
65
|
+
let usersResponse = [];
|
|
66
|
+
for (const user of users) {
|
|
67
|
+
const userGrants = yield this.permissionService.getUserRolesAndGrants(user.codiceUtente);
|
|
68
|
+
let extensionFields = {};
|
|
69
|
+
for (const ext of this.accessiOptions.extensionFieldsOptions) {
|
|
70
|
+
const values = (yield Orm_1.Orm.query(ext.databaseOptions, `SELECT ${ext.tableFields.join(",")} FROM ${ext.tableName} WHERE ${ext.tableJoinFieldName} = ?`, [user.codiceUtente])).map(Utilities_1.RestUtilities.convertKeysToCamelCase);
|
|
71
|
+
extensionFields[ext.objectKey] = values;
|
|
72
|
+
}
|
|
73
|
+
let userResult = {
|
|
74
|
+
utente: user,
|
|
75
|
+
userGrants: userGrants,
|
|
76
|
+
extensionFields: extensionFields
|
|
77
|
+
};
|
|
78
|
+
usersResponse.push(userResult);
|
|
79
|
+
}
|
|
80
|
+
return usersResponse;
|
|
65
81
|
}
|
|
66
82
|
catch (error) {
|
|
67
83
|
throw error;
|