emilsoftware-utilities 1.4.0 → 1.5.0-dev.2

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.
Files changed (35) hide show
  1. package/README.MD +34 -0
  2. package/dist/Utilities.d.ts +1 -0
  3. package/dist/Utilities.js +8 -0
  4. package/dist/accessi-module/AccessiModule.d.ts +11 -2
  5. package/dist/accessi-module/AccessiModule.js +7 -4
  6. package/dist/accessi-module/Controllers/AuthController.js +18 -0
  7. package/dist/accessi-module/Controllers/EmailController.d.ts +1 -0
  8. package/dist/accessi-module/Controllers/EmailController.js +33 -6
  9. package/dist/accessi-module/Controllers/FiltriController.d.ts +11 -0
  10. package/dist/accessi-module/Controllers/FiltriController.js +106 -0
  11. package/dist/accessi-module/Controllers/UserController.d.ts +2 -0
  12. package/dist/accessi-module/Controllers/UserController.js +132 -30
  13. package/dist/accessi-module/Dtos/FiltriUtente.d.ts +59 -7
  14. package/dist/accessi-module/Dtos/FiltriUtente.js +92 -33
  15. package/dist/accessi-module/Dtos/RegisterRequest.d.ts +6 -9
  16. package/dist/accessi-module/Dtos/RegisterRequest.js +52 -38
  17. package/dist/accessi-module/Dtos/SetStatoRegistrazione.d.ts +5 -0
  18. package/dist/accessi-module/Dtos/SetStatoRegistrazione.js +32 -0
  19. package/dist/accessi-module/Dtos/StatoRegistrazione.d.ts +1 -0
  20. package/dist/accessi-module/Dtos/StatoRegistrazione.js +2 -1
  21. package/dist/accessi-module/Dtos/TipoFiltro.d.ts +13 -0
  22. package/dist/accessi-module/Dtos/TipoFiltro.js +90 -0
  23. package/dist/accessi-module/Dtos/UserDto.d.ts +4 -9
  24. package/dist/accessi-module/Dtos/UserDto.js +66 -53
  25. package/dist/accessi-module/Services/AuthService/AuthService.d.ts +3 -1
  26. package/dist/accessi-module/Services/AuthService/AuthService.js +24 -13
  27. package/dist/accessi-module/Services/EmailService/EmailService.d.ts +1 -1
  28. package/dist/accessi-module/Services/EmailService/EmailService.js +70 -32
  29. package/dist/accessi-module/Services/FiltriService/FiltriService.d.ts +11 -0
  30. package/dist/accessi-module/Services/FiltriService/FiltriService.js +126 -0
  31. package/dist/accessi-module/Services/UserService/UserService.d.ts +12 -9
  32. package/dist/accessi-module/Services/UserService/UserService.js +149 -57
  33. package/dist/emilsoftware-utilities-1.5.0-dev.2.tgz +0 -0
  34. package/package.json +1 -1
  35. package/dist/emilsoftware-utilities-1.4.0.tgz +0 -0
@@ -14,15 +14,16 @@ const swagger_1 = require("@nestjs/swagger");
14
14
  const StatoRegistrazione_1 = require("./StatoRegistrazione");
15
15
  const Permission_1 = require("./Permission");
16
16
  const TipoAbilitazione_1 = require("./TipoAbilitazione");
17
- class UserDto {
17
+ const FiltriUtente_1 = require("./FiltriUtente");
18
+ class UserDto extends (0, swagger_1.OmitType)(FiltriUtente_1.FiltriUtente, ['codUte']) {
18
19
  }
19
20
  exports.UserDto = UserDto;
20
21
  __decorate([
21
- (0, swagger_1.ApiProperty)({ description: "Codice identificativo univoco dell'utente.", example: "USR123" }),
22
+ (0, swagger_1.ApiProperty)({ description: "Codice identificativo univoco dell'utente.", example: 'USR123' }),
22
23
  __metadata("design:type", Number)
23
24
  ], UserDto.prototype, "codiceUtente", void 0);
24
25
  __decorate([
25
- (0, swagger_1.ApiProperty)({ description: "Email dell'utente.", example: "mario.rossi@dev.it" }),
26
+ (0, swagger_1.ApiProperty)({ description: "Email dell'utente.", example: 'mario.rossi@dev.it' }),
26
27
  __metadata("design:type", String)
27
28
  ], UserDto.prototype, "email", void 0);
28
29
  __decorate([
@@ -30,106 +31,118 @@ __decorate([
30
31
  __metadata("design:type", Boolean)
31
32
  ], UserDto.prototype, "flagGdpr", void 0);
32
33
  __decorate([
33
- (0, swagger_1.ApiPropertyOptional)({ description: "Data di accettazione del GDPR.", format: "date-time", example: "2024-03-18T12:34:56Z" }),
34
+ (0, swagger_1.ApiPropertyOptional)({
35
+ description: 'Data di accettazione del GDPR.',
36
+ format: 'date-time',
37
+ example: '2024-03-18T12:34:56Z',
38
+ }),
34
39
  __metadata("design:type", String)
35
40
  ], UserDto.prototype, "dataGdpr", void 0);
36
41
  __decorate([
37
- (0, swagger_1.ApiPropertyOptional)({ description: "Data di inserimento dell'utente nel sistema.", format: "date-time", example: "2023-01-01T08:30:00Z" }),
42
+ (0, swagger_1.ApiPropertyOptional)({
43
+ description: "Data di inserimento dell'utente nel sistema.",
44
+ format: 'date-time',
45
+ example: '2023-01-01T08:30:00Z',
46
+ }),
38
47
  __metadata("design:type", String)
39
48
  ], UserDto.prototype, "dataInserimento", void 0);
40
49
  __decorate([
41
- (0, swagger_1.ApiPropertyOptional)({ description: "Data scadenza password.", format: "date-time", example: "2025-06-01" }),
50
+ (0, swagger_1.ApiPropertyOptional)({
51
+ description: 'Data scadenza password.',
52
+ format: 'date-time',
53
+ example: '2025-06-01',
54
+ }),
42
55
  __metadata("design:type", String)
43
56
  ], UserDto.prototype, "dataScadenzaPassword", void 0);
44
57
  __decorate([
45
- (0, swagger_1.ApiPropertyOptional)({ description: "Ultima data di accesso dell'utente.", format: "date-time", example: "2024-03-15T14:45:00Z" }),
58
+ (0, swagger_1.ApiPropertyOptional)({
59
+ description: "Ultima data di accesso dell'utente.",
60
+ format: 'date-time',
61
+ example: '2024-03-15T14:45:00Z',
62
+ }),
46
63
  __metadata("design:type", String)
47
64
  ], UserDto.prototype, "dataLastLogin", void 0);
48
65
  __decorate([
49
- (0, swagger_1.ApiPropertyOptional)({ description: "Stato della registrazione dell'utente.", enum: StatoRegistrazione_1.StatoRegistrazione, example: StatoRegistrazione_1.StatoRegistrazione.CONF }),
66
+ (0, swagger_1.ApiPropertyOptional)({
67
+ description: "Stato della registrazione dell'utente.",
68
+ enum: StatoRegistrazione_1.StatoRegistrazione,
69
+ example: StatoRegistrazione_1.StatoRegistrazione.CONF,
70
+ }),
50
71
  __metadata("design:type", Number)
51
72
  ], UserDto.prototype, "statoRegistrazione", void 0);
52
73
  __decorate([
53
- (0, swagger_1.ApiPropertyOptional)({ description: "Chiave di registrazione dell'utente.", example: "abc123xyz" }),
74
+ (0, swagger_1.ApiPropertyOptional)({
75
+ description: "Chiave di registrazione dell'utente.",
76
+ example: 'abc123xyz',
77
+ }),
54
78
  __metadata("design:type", String)
55
79
  ], UserDto.prototype, "keyRegistrazione", void 0);
56
80
  __decorate([
57
- (0, swagger_1.ApiPropertyOptional)({ description: "Cognome dell'utente.", example: "Rossi" }),
81
+ (0, swagger_1.ApiPropertyOptional)({ description: "Cognome dell'utente.", example: 'Rossi' }),
58
82
  __metadata("design:type", String)
59
83
  ], UserDto.prototype, "cognome", void 0);
60
84
  __decorate([
61
- (0, swagger_1.ApiPropertyOptional)({ description: "Nome dell'utente.", example: "Mario" }),
85
+ (0, swagger_1.ApiPropertyOptional)({ description: "Nome dell'utente.", example: 'Mario' }),
62
86
  __metadata("design:type", String)
63
87
  ], UserDto.prototype, "nome", void 0);
64
88
  __decorate([
65
- (0, swagger_1.ApiPropertyOptional)({ description: "Avatar (URL o base64).", example: "https://example.com/avatar.jpg", nullable: true }),
89
+ (0, swagger_1.ApiPropertyOptional)({
90
+ description: 'Avatar (URL o base64).',
91
+ example: 'https://example.com/avatar.jpg',
92
+ nullable: true,
93
+ }),
66
94
  __metadata("design:type", String)
67
95
  ], UserDto.prototype, "avatar", void 0);
68
96
  __decorate([
69
- (0, swagger_1.ApiPropertyOptional)({ description: "Flag che indica se l'autenticazione a due fattori è attivata.", example: true }),
97
+ (0, swagger_1.ApiPropertyOptional)({
98
+ description: "Flag che indica se l'autenticazione a due fattori è attivata.",
99
+ example: true,
100
+ }),
70
101
  __metadata("design:type", Boolean)
71
102
  ], UserDto.prototype, "flagDueFattori", void 0);
72
103
  __decorate([
73
- (0, swagger_1.ApiPropertyOptional)({ description: "Codice lingua preferito.", example: "it" }),
104
+ (0, swagger_1.ApiPropertyOptional)({ description: 'Codice lingua preferito.', example: 'it' }),
74
105
  __metadata("design:type", String)
75
106
  ], UserDto.prototype, "codiceLingua", void 0);
76
107
  __decorate([
77
- (0, swagger_1.ApiPropertyOptional)({ description: "Numero di cellulare.", example: "+393401234567", nullable: true }),
108
+ (0, swagger_1.ApiPropertyOptional)({
109
+ description: 'Numero di cellulare.',
110
+ example: '+393401234567',
111
+ nullable: true,
112
+ }),
78
113
  __metadata("design:type", String)
79
114
  ], UserDto.prototype, "cellulare", void 0);
80
115
  __decorate([
81
- (0, swagger_1.ApiPropertyOptional)({ description: "Flag superutente.", example: false }),
116
+ (0, swagger_1.ApiPropertyOptional)({ description: 'Flag superutente.', example: false }),
82
117
  __metadata("design:type", Boolean)
83
118
  ], UserDto.prototype, "flagSuper", void 0);
84
119
  __decorate([
85
- (0, swagger_1.ApiPropertyOptional)({ description: "Pagina di default dell'utente all'accesso.", example: "/dashboard" }),
120
+ (0, swagger_1.ApiPropertyOptional)({
121
+ description: "Pagina di default dell'utente all'accesso.",
122
+ example: '/dashboard',
123
+ }),
86
124
  __metadata("design:type", String)
87
125
  ], UserDto.prototype, "paginaDefault", void 0);
88
126
  __decorate([
89
- (0, swagger_1.ApiPropertyOptional)({ description: "Metadata JSON personalizzato.", example: "{\"theme\": \"dark\"}" }),
127
+ (0, swagger_1.ApiPropertyOptional)({
128
+ description: 'Metadata JSON personalizzato.',
129
+ example: '{"theme": "dark"}',
130
+ }),
90
131
  __metadata("design:type", String)
91
132
  ], UserDto.prototype, "jsonMetadata", void 0);
92
133
  __decorate([
93
- (0, swagger_1.ApiPropertyOptional)({ description: "Ragione sociale cliente.", example: "ACME Corp SpA" }),
134
+ (0, swagger_1.ApiPropertyOptional)({ description: 'Ragione sociale cliente.', example: 'ACME Corp SpA' }),
94
135
  __metadata("design:type", String)
95
136
  ], UserDto.prototype, "ragSocCli", void 0);
96
137
  __decorate([
97
- (0, swagger_1.ApiPropertyOptional)({ description: "Ruoli assegnati all'utente.", example: ["admin", "editor"] }),
138
+ (0, swagger_1.ApiPropertyOptional)({ description: "Ruoli assegnati all'utente.", example: ['admin', 'editor'] }),
98
139
  __metadata("design:type", Array)
99
140
  ], UserDto.prototype, "roles", void 0);
100
141
  __decorate([
101
- (0, swagger_1.ApiPropertyOptional)({ description: "Permessi assegnati all'utente.", type: [Permission_1.Permission], example: [{ codiceMenu: "MNUOFFICINA", tipoAbilitazione: TipoAbilitazione_1.TipoAbilitazione.SCRITTURA }] }),
142
+ (0, swagger_1.ApiPropertyOptional)({
143
+ description: "Permessi assegnati all'utente.",
144
+ type: [Permission_1.Permission],
145
+ example: [{ codiceMenu: 'MNUOFFICINA', tipoAbilitazione: TipoAbilitazione_1.TipoAbilitazione.SCRITTURA }],
146
+ }),
102
147
  __metadata("design:type", Array)
103
148
  ], UserDto.prototype, "permissions", void 0);
104
- __decorate([
105
- (0, swagger_1.ApiPropertyOptional)({ description: "Progressivo interno.", example: 1001 }),
106
- __metadata("design:type", Number)
107
- ], UserDto.prototype, "prog", void 0);
108
- __decorate([
109
- (0, swagger_1.ApiPropertyOptional)({ description: "Numero di report.", example: 5 }),
110
- __metadata("design:type", Number)
111
- ], UserDto.prototype, "numRep", void 0);
112
- __decorate([
113
- (0, swagger_1.ApiPropertyOptional)({ description: "Indice personalizzato.", example: 200 }),
114
- __metadata("design:type", Number)
115
- ], UserDto.prototype, "idxPers", void 0);
116
- __decorate([
117
- (0, swagger_1.ApiPropertyOptional)({ description: "Codice cliente super.", example: "CLI001" }),
118
- __metadata("design:type", String)
119
- ], UserDto.prototype, "codiceClienteSuper", void 0);
120
- __decorate([
121
- (0, swagger_1.ApiPropertyOptional)({ description: "Codice agente.", example: "AGT456" }),
122
- __metadata("design:type", String)
123
- ], UserDto.prototype, "codiceAge", void 0);
124
- __decorate([
125
- (0, swagger_1.ApiPropertyOptional)({ description: "Codice cliente collettivo.", example: "CLCOL789" }),
126
- __metadata("design:type", String)
127
- ], UserDto.prototype, "codiceClienteCol", void 0);
128
- __decorate([
129
- (0, swagger_1.ApiPropertyOptional)({ description: "Codici multipli clienti.", example: "CLI001, CLI002" }),
130
- __metadata("design:type", String)
131
- ], UserDto.prototype, "codiceClienti", void 0);
132
- __decorate([
133
- (0, swagger_1.ApiPropertyOptional)({ description: "Tipo di filiale.", example: "HQ" }),
134
- __metadata("design:type", String)
135
- ], UserDto.prototype, "tipoFil", void 0);
@@ -3,11 +3,13 @@ import { UserService } from "../UserService/UserService";
3
3
  import { PermissionService } from "../PermissionService/PermissionService";
4
4
  import { LoginRequest } from "../../Dtos/LoginRequest";
5
5
  import { LoginResult } from "../../Dtos/LoginResponse";
6
+ import { FiltriService } from "../FiltriService/FiltriService";
6
7
  export declare class AuthService {
7
8
  private userService;
8
9
  private permissionService;
10
+ private filtriService;
9
11
  private readonly accessiOptions;
10
- constructor(userService: UserService, permissionService: PermissionService, accessiOptions: AccessiOptions);
12
+ constructor(userService: UserService, permissionService: PermissionService, filtriService: FiltriService, accessiOptions: AccessiOptions);
11
13
  login(request: LoginRequest): Promise<LoginResult>;
12
14
  setPassword(codiceUtente: number, nuovaPassword: string): Promise<any>;
13
15
  verifyPassword(codiceUtente: number, passwordCifrata: string): Promise<boolean>;
@@ -28,17 +28,21 @@ const StatoRegistrazione_1 = require("../../Dtos/StatoRegistrazione");
28
28
  const common_1 = require("@nestjs/common");
29
29
  const UserService_1 = require("../UserService/UserService");
30
30
  const PermissionService_1 = require("../PermissionService/PermissionService");
31
+ const FiltriService_1 = require("../FiltriService/FiltriService");
31
32
  let AuthService = class AuthService {
32
- constructor(userService, permissionService, accessiOptions) {
33
+ constructor(userService, permissionService, filtriService, accessiOptions) {
33
34
  this.userService = userService;
34
35
  this.permissionService = permissionService;
36
+ this.filtriService = filtriService;
35
37
  this.accessiOptions = accessiOptions;
36
38
  }
37
39
  login(request) {
38
40
  return __awaiter(this, void 0, void 0, function* () {
39
- if (this.accessiOptions.mockDemoUser && request.email.toLowerCase() === "demo")
41
+ if (this.accessiOptions.mockDemoUser &&
42
+ request.email.toLowerCase() === "demo")
40
43
  return this.getDemoUser();
41
- if (this.accessiOptions.mockDemoUser && request.email.toLowerCase() === "admin")
44
+ if (this.accessiOptions.mockDemoUser &&
45
+ request.email.toLowerCase() === "admin")
42
46
  return this.getAdminUser();
43
47
  const passwordCifrata = Utilities_1.CryptUtilities.encrypt(request.password, this.accessiOptions.encryptionKey);
44
48
  const utente = yield this.userService.getUserByEmail(request.email.toLowerCase());
@@ -61,21 +65,27 @@ let AuthService = class AuthService {
61
65
  const isPasswordValid = yield this.verifyPassword(utente.codiceUtente, passwordCifrata);
62
66
  if (!isPasswordValid)
63
67
  throw new Error("Nome utente o password errata!");
64
- const today = new Date();
65
- const targetDate = new Date(utente.dataScadenzaPassword);
66
- if (today >= targetDate) {
67
- throw new Error("Password scaduta!");
68
+ if (this.accessiOptions.passwordExpiration &&
69
+ this.accessiOptions.passwordExpiration == true) {
70
+ const today = new Date();
71
+ const targetDate = new Date(utente.dataScadenzaPassword);
72
+ if (today >= targetDate) {
73
+ throw new Error("PASSWORD_EXPIRED");
74
+ }
68
75
  }
69
76
  // Recupera i grants
70
77
  const userGrants = yield this.permissionService.getUserRolesAndGrants(utente.codiceUtente);
71
78
  // Recupera i filtri
72
- const filtri = yield this.userService.getUserFilters(utente.codiceUtente);
79
+ const filtri = yield this.filtriService.getFiltriUser(utente.codiceUtente);
73
80
  const updateLastAccessDateQuery = "UPDATE UTENTI SET DATLASTLOGIN = CURRENT_TIMESTAMP WHERE CODUTE = ?";
74
81
  yield Orm_1.Orm.query(this.accessiOptions.databaseOptions, updateLastAccessDateQuery, [utente.codiceUtente]);
75
82
  let extensionFields = {};
76
- for (const ext of this.accessiOptions.extensionFieldsOptions) {
77
- const values = (yield Orm_1.Orm.query(ext.databaseOptions, `SELECT ${ext.tableFields.join(",")} FROM ${ext.tableName} WHERE ${ext.tableJoinFieldName} = ?`, [utente.codiceUtente])).map(Utilities_1.RestUtilities.convertKeysToCamelCase);
78
- extensionFields[ext.objectKey] = values;
83
+ if (this.accessiOptions.extensionFieldsOptions &&
84
+ this.accessiOptions.extensionFieldsOptions.length > 0) {
85
+ for (const ext of this.accessiOptions.extensionFieldsOptions) {
86
+ const values = (yield Orm_1.Orm.query(ext.databaseOptions, `SELECT ${ext.tableFields.join(",")} FROM ${ext.tableName} WHERE ${ext.tableJoinFieldName} = ?`, [utente.codiceUtente])).map(Utilities_1.RestUtilities.convertKeysToCamelCase);
87
+ extensionFields[ext.objectKey] = values;
88
+ }
79
89
  }
80
90
  return { utente, filtri, userGrants, extensionFields };
81
91
  });
@@ -180,7 +190,8 @@ let AuthService = class AuthService {
180
190
  exports.AuthService = AuthService;
181
191
  exports.AuthService = AuthService = __decorate([
182
192
  (0, common_1.Injectable)(),
183
- __param(2, (0, common_1.Inject)("ACCESSI_OPTIONS")),
193
+ __param(3, (0, common_1.Inject)("ACCESSI_OPTIONS")),
184
194
  __metadata("design:paramtypes", [UserService_1.UserService,
185
- PermissionService_1.PermissionService, Object])
195
+ PermissionService_1.PermissionService,
196
+ FiltriService_1.FiltriService, Object])
186
197
  ], AuthService);
@@ -4,6 +4,6 @@ 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): Promise<void>;
7
+ sendPasswordResetEmail(email: string, htmlMail?: string): Promise<void>;
8
8
  private GetHtmlMail;
9
9
  }
@@ -38,21 +38,33 @@ 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, htmlMail) {
42
42
  return __awaiter(this, void 0, void 0, function* () {
43
43
  var _a;
44
44
  try {
45
45
  const resetToken = (0, uuid_1.v4)(); // Generiamo un nuovo token unico
46
+ console.log('Generated reset token:', resetToken);
46
47
  // Aggiorna il campo keyReg nel database
47
- const result = yield Orm_1.Orm.query(this.accessiOptions.databaseOptions, "UPDATE UTENTI SET KEYREG = ?, STAREG = ? WHERE USRNAME = ? RETURNING CODUTE", [resetToken, StatoRegistrazione_1.StatoRegistrazione.INVIO, email]);
48
- if (result.length === 0) {
49
- throw new Error("Email non trovata.");
48
+ const result = yield Orm_1.Orm.execute(this.accessiOptions.databaseOptions, 'UPDATE UTENTI SET KEYREG = ?, STAREG = ? WHERE USRNAME = ? ', [resetToken, StatoRegistrazione_1.StatoRegistrazione.INVIO, email]);
49
+ //costruizione dei queryparams
50
+ const returnUrlQueryParams = '?returnUrl=' +
51
+ this.accessiOptions.confirmationEmailReturnUrl +
52
+ '&prefix=' +
53
+ ((_a = this.accessiOptions.confirmationEmailPrefix) !== null && _a !== void 0 ? _a : '');
54
+ const { confirmationEmailUrl, customResetPage } = this.accessiOptions;
55
+ // costruisco l'url di base
56
+ let resetUrl = `${confirmationEmailUrl}/api/accessi/email/reset-password-page/${resetToken}${returnUrlQueryParams}`;
57
+ //solo se gli do la customResetPage
58
+ if (customResetPage) {
59
+ resetUrl = customResetPage + '?token=' + resetToken;
50
60
  }
51
- const returnUrlQueryParams = "?returnUrl=" + this.accessiOptions.confirmationEmailReturnUrl + "&prefix=" + ((_a = this.accessiOptions.confirmationEmailPrefix) !== null && _a !== void 0 ? _a : '');
52
- const { confirmationEmailUrl } = this.accessiOptions;
53
- const resetUrl = `${confirmationEmailUrl}/api/accessi/email/reset-password-page/${resetToken}${returnUrlQueryParams}`;
54
61
  let sPhrase;
55
- sPhrase = ` Gentile utente,<br>
62
+ if (htmlMail) {
63
+ sPhrase = htmlMail;
64
+ sPhrase.replace('#link_conferma_password_url', resetUrl);
65
+ }
66
+ else {
67
+ sPhrase = ` Gentile utente,<br>
56
68
  abbiamo ricevuto la tua richiesta.<br><br>
57
69
 
58
70
  Per completare l'operazione, clicca sul link qui sotto:<br>
@@ -64,11 +76,12 @@ let EmailService = class EmailService {
64
76
  Questa è una comunicazione automatica, ti preghiamo di non rispondere a questa email.<br><br>
65
77
 
66
78
  Grazie.<br>`;
79
+ }
67
80
  const html = this.GetHtmlMail(sPhrase);
68
81
  const mailOptions = {
69
82
  from: this.accessiOptions.emailOptions.from,
70
83
  to: email,
71
- subject: "Scelta nuova password",
84
+ subject: 'Scelta nuova password',
72
85
  text: sPhrase,
73
86
  html: html,
74
87
  };
@@ -192,7 +205,8 @@ let EmailService = class EmailService {
192
205
  sTxt += ' table.kmSplitContentRightContentContainer,';
193
206
  sTxt += ' table.kmColumnContainer,';
194
207
  sTxt += ' td.kmVerticalButtonBarContentOuter table.kmButtonBarContent,';
195
- sTxt += ' td.kmVerticalButtonCollectionContentOuter table.kmButtonCollectionContent,';
208
+ sTxt +=
209
+ ' td.kmVerticalButtonCollectionContentOuter table.kmButtonCollectionContent,';
196
210
  sTxt += ' table.kmVerticalButton,';
197
211
  sTxt += ' table.kmVerticalButtonContent {';
198
212
  sTxt += ' width: 100% !important';
@@ -272,44 +286,68 @@ let EmailService = class EmailService {
272
286
  sTxt += ' }';
273
287
  sTxt += ' </style>';
274
288
  sTxt += '</head>';
275
- sTxt += '<body style="margin:0;padding:0;font-family:"Raleway", Helvetica, sans-serif;font-weight:400;letter-spacing:0.75px;line-height:180%;background-color:#F2F2F2">';
289
+ sTxt +=
290
+ '<body style="margin:0;padding:0;font-family:"Raleway", Helvetica, sans-serif;font-weight:400;letter-spacing:0.75px;line-height:180%;background-color:#F2F2F2">';
276
291
  sTxt += ' <center>';
277
- sTxt += ' <table align="center" border="0" cellpadding="0" cellspacing="0" id="bodyTable" width="100%" style="border-collapse:collapse;mso-table-lspace:0;mso-table-rspace:0;padding:0;background-color:#F2F2F2;height:100%;margin:0;width:100%">';
292
+ sTxt +=
293
+ ' <table align="center" border="0" cellpadding="0" cellspacing="0" id="bodyTable" width="100%" style="border-collapse:collapse;mso-table-lspace:0;mso-table-rspace:0;padding:0;background-color:#F2F2F2;height:100%;margin:0;width:100%">';
278
294
  sTxt += ' <tbody>';
279
295
  sTxt += ' <tr>';
280
- sTxt += ' <td align="center" id="bodyCell" valign="top" style="border-collapse:collapse;mso-table-lspace:0;mso-table-rspace:0;padding-top:10px;padding-left:10px;padding-bottom:20px;padding-right:10px;border-top:0;height:100%;margin:0;width:100%">';
296
+ sTxt +=
297
+ ' <td align="center" id="bodyCell" valign="top" style="border-collapse:collapse;mso-table-lspace:0;mso-table-rspace:0;padding-top:10px;padding-left:10px;padding-bottom:20px;padding-right:10px;border-top:0;height:100%;margin:0;width:100%">';
281
298
  sTxt += ' <!--[if !mso]>';
282
299
  sTxt += ' <!-->';
283
- sTxt += ' <div class="templateContainer" style="border:0 none #aaa;background-color:#F2F2F2;border-radius:0;display: table; width:90%">';
300
+ sTxt +=
301
+ ' <div class="templateContainer" style="border:0 none #aaa;background-color:#F2F2F2;border-radius:0;display: table; width:90%">';
284
302
  sTxt += ' <div class="templateContainerInner" style="padding:0">';
285
303
  sTxt += ' <!--';
286
304
  sTxt += ' <![endif]-->';
287
305
  sTxt += ' <!--[if mso]>';
288
- sTxt += ' <table border="0" cellpadding="0" cellspacing="0" class="templateContainer" width="90%" ';
289
- sTxt += ' style="border-collapse:collapse;mso-table-lspace:0;mso-table-rspace:0;">';
306
+ sTxt +=
307
+ ' <table border="0" cellpadding="0" cellspacing="0" class="templateContainer" width="90%" ';
308
+ sTxt +=
309
+ ' style="border-collapse:collapse;mso-table-lspace:0;mso-table-rspace:0;">';
290
310
  sTxt += ' <tbody>';
291
311
  sTxt += ' <tr>';
292
- sTxt += ' <td class="templateContainerInner" style="border-collapse:collapse;mso-table-lspace:0;mso-table-rspace:0;">';
312
+ sTxt +=
313
+ ' <td class="templateContainerInner" style="border-collapse:collapse;mso-table-lspace:0;mso-table-rspace:0;">';
293
314
  sTxt += ' <![endif]-->';
294
- sTxt += ' <table border="0" cellpadding="0" cellspacing="0" width="100%" style="border-collapse:collapse;mso-table-lspace:0;mso-table-rspace:0">';
315
+ sTxt +=
316
+ ' <table border="0" cellpadding="0" cellspacing="0" width="100%" style="border-collapse:collapse;mso-table-lspace:0;mso-table-rspace:0">';
295
317
  sTxt += ' <tr>';
296
- sTxt += ' <td align="center" valign="top" style="border-collapse:collapse;mso-table-lspace:0;mso-table-rspace:0">';
297
- sTxt += ' <table border="0" cellpadding="0" cellspacing="0" class="templateRow" width="100%" style="border-collapse:collapse;mso-table-lspace:0;mso-table-rspace:0">';
318
+ sTxt +=
319
+ ' <td align="center" valign="top" style="border-collapse:collapse;mso-table-lspace:0;mso-table-rspace:0">';
320
+ sTxt +=
321
+ ' <table border="0" cellpadding="0" cellspacing="0" class="templateRow" width="100%" style="border-collapse:collapse;mso-table-lspace:0;mso-table-rspace:0">';
298
322
  sTxt += ' <tbody>';
299
323
  sTxt += ' <tr>';
300
- sTxt += ' <td class="rowContainer kmFloatLeft" valign="top" style="border-collapse:collapse;mso-table-lspace:0;mso-table-rspace:0">';
301
- sTxt += ' <table border="0" cellpadding="0" cellspacing="0" class="kmTextBlock" width="100%" style="border-collapse:collapse;mso-table-lspace:0;mso-table-rspace:0">';
302
- sTxt += ' <tbody class="kmTextBlockOuter">';
324
+ sTxt +=
325
+ ' <td class="rowContainer kmFloatLeft" valign="top" style="border-collapse:collapse;mso-table-lspace:0;mso-table-rspace:0">';
326
+ sTxt +=
327
+ ' <table border="0" cellpadding="0" cellspacing="0" class="kmTextBlock" width="100%" style="border-collapse:collapse;mso-table-lspace:0;mso-table-rspace:0">';
328
+ sTxt +=
329
+ ' <tbody class="kmTextBlockOuter">';
303
330
  sTxt += ' <tr>';
304
- sTxt += ' <td class="kmTextBlockInner" valign="top" style="border-collapse:collapse;mso-table-lspace:0;mso-table-rspace:0;background-color:#FFFFFF;">';
305
- sTxt += ' <table align="left" border="0" cellpadding="0" cellspacing="0" class="kmTextContentContainer" width="100%" style="border-collapse:collapse;mso-table-lspace:0;mso-table-rspace:0">';
306
- sTxt += ' <tbody>';
307
- sTxt += ' <tr>';
308
- sTxt += ' <td class="kmTextContent" valign="top" style="border-collapse:collapse;mso-table-lspace:0;mso-table-rspace:0;color:#272727;font-family:Helvetica, Arial;font-size:13px;line-height:200%;letter-spacing:normal;text-align:left;padding-top:40px;padding-bottom:40px;padding-left:40px;padding-right:40px;">';
309
- sTxt += ' <p>' + sPhrase + '<p>';
310
- sTxt += ' </td>';
311
- sTxt += ' </tr>';
312
- sTxt += ' </tbody>';
331
+ sTxt +=
332
+ ' <td class="kmTextBlockInner" valign="top" style="border-collapse:collapse;mso-table-lspace:0;mso-table-rspace:0;background-color:#FFFFFF;">';
333
+ sTxt +=
334
+ ' <table align="left" border="0" cellpadding="0" cellspacing="0" class="kmTextContentContainer" width="100%" style="border-collapse:collapse;mso-table-lspace:0;mso-table-rspace:0">';
335
+ sTxt +=
336
+ ' <tbody>';
337
+ sTxt +=
338
+ ' <tr>';
339
+ sTxt +=
340
+ ' <td class="kmTextContent" valign="top" style="border-collapse:collapse;mso-table-lspace:0;mso-table-rspace:0;color:#272727;font-family:Helvetica, Arial;font-size:13px;line-height:200%;letter-spacing:normal;text-align:left;padding-top:40px;padding-bottom:40px;padding-left:40px;padding-right:40px;">';
341
+ sTxt +=
342
+ ' <p>' +
343
+ sPhrase +
344
+ '<p>';
345
+ sTxt +=
346
+ ' </td>';
347
+ sTxt +=
348
+ ' </tr>';
349
+ sTxt +=
350
+ ' </tbody>';
313
351
  sTxt += ' </table>';
314
352
  sTxt += ' </td>';
315
353
  sTxt += ' </tr>';
@@ -0,0 +1,11 @@
1
+ import { AccessiOptions } from '../../AccessiModule';
2
+ import { TipoFiltro } from '../../Dtos/TipoFiltro';
3
+ import { FiltriUtente } from '../../Dtos';
4
+ export declare class FiltriService {
5
+ private readonly accessiOptions;
6
+ private readonly logger;
7
+ constructor(accessiOptions: AccessiOptions);
8
+ getTipoFiltri(): Promise<TipoFiltro[]>;
9
+ getFiltriUser(codUte: number): Promise<FiltriUtente[]>;
10
+ upsertFiltriUtente(codUte: number, dto: Partial<FiltriUtente>): Promise<void>;
11
+ }
@@ -0,0 +1,126 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
15
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
16
+ return new (P || (P = Promise))(function (resolve, reject) {
17
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
18
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
19
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
20
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
21
+ });
22
+ };
23
+ var FiltriService_1;
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ exports.FiltriService = void 0;
26
+ const common_1 = require("@nestjs/common");
27
+ const Orm_1 = require("../../../Orm");
28
+ const Utilities_1 = require("../../../Utilities");
29
+ const Logger_1 = require("../../../Logger");
30
+ const Dtos_1 = require("../../Dtos");
31
+ let FiltriService = FiltriService_1 = class FiltriService {
32
+ constructor(accessiOptions) {
33
+ this.accessiOptions = accessiOptions;
34
+ this.logger = new Logger_1.Logger(FiltriService_1.name);
35
+ }
36
+ getTipoFiltri() {
37
+ return __awaiter(this, void 0, void 0, function* () {
38
+ try {
39
+ let getQuery = 'SELECT TIPFIL AS TIP_FIL, DESFIL AS DES_FIL, FLDFIL AS FLD_FIL, FLGENABLED AS FLG_ENABLED FROM FILTRI_TIPO';
40
+ const params = [];
41
+ let result = yield Orm_1.Orm.query(this.accessiOptions.databaseOptions, getQuery, params);
42
+ return result.map(Utilities_1.RestUtilities.convertKeysToCamelCase);
43
+ }
44
+ catch (error) {
45
+ this.logger.error('Errore durante il recupero dei tipi di filtri', error);
46
+ throw error;
47
+ }
48
+ });
49
+ }
50
+ getFiltriUser(codUte) {
51
+ return __awaiter(this, void 0, void 0, function* () {
52
+ try {
53
+ let params = [];
54
+ let getQuery = `SELECT CODUTE AS COD_UTE, PROG AS PROGRESSIVO, NUMREP AS NUM_REP, IDXPERS AS IDX_PERS, CODCLISUPER AS COD_CLI_SUPER, CODAGE AS COD_AGE, CODCLICOL AS COD_CLI_COL,
55
+ CODCLIENTI AS COD_CLIENTI, TIPFIL AS TIP_FIL, CODDIP AS COD_DIP, IDXPOS AS IDX_POS FROM FILTRI `;
56
+ if (codUte === undefined) {
57
+ this.logger.log('Nessun utente passato, recupero i filtri di tutti gli utenti...');
58
+ }
59
+ else {
60
+ this.logger.log('codUte passato, recupero i filtri dell utente ' + codUte);
61
+ getQuery += ' WHERE CODUTE = ?';
62
+ params.push(codUte);
63
+ }
64
+ let result = yield Orm_1.Orm.query(this.accessiOptions.databaseOptions, getQuery, params);
65
+ return result.map(Utilities_1.RestUtilities.convertKeysToCamelCase);
66
+ }
67
+ catch (error) {
68
+ throw error;
69
+ }
70
+ });
71
+ }
72
+ upsertFiltriUtente(codUte, dto) {
73
+ return __awaiter(this, void 0, void 0, function* () {
74
+ try {
75
+ console.debug('Dati utente da aggiornare: ', dto);
76
+ if (!codUte || codUte <= 0)
77
+ throw new Error('Codice utente non valido');
78
+ const dbFields = ['CODUTE'];
79
+ const values = [codUte];
80
+ //aggiungo solo campi valorizzati
81
+ for (const [key, cfg] of Object.entries(Dtos_1.FILTRI_UTENTE_DB_MAPPING)) {
82
+ console.log('valuto campo: ', key);
83
+ const value = dto[key];
84
+ //gestione campi vuoti, null o undefined
85
+ if (value === undefined) {
86
+ console.log(`Campo ${key} vuoto: ${value}`);
87
+ continue;
88
+ }
89
+ if (value === null || value === '') {
90
+ dbFields.push(cfg.dbField);
91
+ values.push(null);
92
+ continue;
93
+ }
94
+ // if (value === undefined || value === null || value === '') {
95
+ // console.log(`Campo ${key} vuoto: ${value}`)
96
+ // continue;
97
+ // }
98
+ if (cfg.numeric && typeof value !== 'number') {
99
+ throw new Error(`Il campo ${key} deve essere un numero`);
100
+ }
101
+ if (!cfg.numeric && typeof value !== 'string') {
102
+ throw new Error(`Il campo ${key} deve essere una stringa`);
103
+ }
104
+ dbFields.push(cfg.dbField);
105
+ values.push(value);
106
+ }
107
+ if (dbFields.length === 1) {
108
+ this.logger.log(`Nessun campo valido da inserire per l'utente ${codUte}`);
109
+ return;
110
+ }
111
+ let sSql = `UPDATE OR INSERT INTO FILTRI (${dbFields.join(',')}) VALUES (${values.map(() => '?').join(', ')}) MATCHING (CODUTE)`;
112
+ yield Orm_1.Orm.execute(this.accessiOptions.databaseOptions, sSql, values);
113
+ this.logger.log('Update or Insert filtri OK per CODUTE = ' + codUte);
114
+ }
115
+ catch (error) {
116
+ throw new Error(`Errore durante update or insert filtri per utente ${codUte}: ${error.message}`);
117
+ }
118
+ });
119
+ }
120
+ };
121
+ exports.FiltriService = FiltriService;
122
+ exports.FiltriService = FiltriService = FiltriService_1 = __decorate([
123
+ (0, common_1.Injectable)(),
124
+ __param(0, (0, common_1.Inject)('ACCESSI_OPTIONS')),
125
+ __metadata("design:paramtypes", [Object])
126
+ ], FiltriService);
@@ -1,15 +1,17 @@
1
- import { AccessiOptions } from "../../AccessiModule";
2
- import { EmailService } from "../EmailService/EmailService";
3
- import { FiltriUtente } from "../../Dtos/FiltriUtente";
4
- import { GetUsersResult } from "../../Dtos/GetUsersResponse";
5
- import { PermissionService } from "../PermissionService/PermissionService";
6
- import { UserDto } from "../../Dtos";
7
- import { RegisterRequest } from "../../Dtos/RegisterRequest";
1
+ import { AccessiOptions } from '../../AccessiModule';
2
+ import { StatoRegistrazione } from '../../Dtos/StatoRegistrazione';
3
+ import { EmailService } from '../EmailService/EmailService';
4
+ import { GetUsersResult } from '../../Dtos/GetUsersResponse';
5
+ import { PermissionService } from '../PermissionService/PermissionService';
6
+ import { UserDto } from '../../Dtos';
7
+ import { RegisterRequest } from '../../Dtos/RegisterRequest';
8
+ import { FiltriService } from '../FiltriService/FiltriService';
8
9
  export declare class UserService {
9
10
  private readonly accessiOptions;
10
11
  private readonly emailService;
11
12
  private readonly permissionService;
12
- constructor(accessiOptions: AccessiOptions, emailService: EmailService, permissionService: PermissionService);
13
+ private readonly filtriService;
14
+ constructor(accessiOptions: AccessiOptions, emailService: EmailService, permissionService: PermissionService, filtriService: FiltriService);
13
15
  getUsers(filters?: {
14
16
  email?: string;
15
17
  codiceUtente?: number;
@@ -21,11 +23,12 @@ export declare class UserService {
21
23
  codiceUtente: number;
22
24
  }>;
23
25
  getUserByEmail(email: string): Promise<UserDto | null>;
24
- getUserFilters(codiceUtente: number): Promise<FiltriUtente[]>;
25
26
  insertUserFilters(codiceUtente: number, filterData: RegisterRequest): Promise<void>;
26
27
  private executeInTransaction;
27
28
  register(registrationData: RegisterRequest): Promise<string>;
28
29
  updateUser(codiceUtente: number, user: UserDto): Promise<void>;
30
+ updateUserFilters(codiceUtente: number, user: UserDto): Promise<void>;
29
31
  deleteUser(codiceCliente: number): Promise<void>;
32
+ setStato(codiceCliente: number, statoRegistrazione: StatoRegistrazione): Promise<void>;
30
33
  setGdpr(codiceUtente: number): Promise<any>;
31
34
  }