emilsoftware-utilities 1.4.0-dev.1 → 1.4.0-dev.3

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/README.MD ADDED
@@ -0,0 +1,34 @@
1
+ Convenzioni per i Commit Message
2
+
3
+ 1. feat:
4
+ Descrizione: Nuova feature
5
+ Esempio: feat: aggiunta endpoint per notifiche
6
+ Trigger: MINOR release (es. 1.3.0 -> 1.4.0)
7
+ Su dev: 1.4.0-dev.0
8
+
9
+ 2. fix:
10
+ Descrizione: Correzione di bug
11
+ Esempio: fix: gestione errore null in login
12
+ Trigger: PATCH release (es. 1.3.1)
13
+ Su dev: 1.3.1-dev.0
14
+
15
+ 3. BREAKING CHANGE:
16
+ Descrizione: Cambiamento che rompe la compatibilità all'indietro
17
+ Esempio:
18
+ feat!: rimozione supporto legacy
19
+ BREAKING CHANGE: cambia lo schema JWT
20
+ Trigger: MAJOR release (es. 1.0.0 -> 2.0.0)
21
+
22
+ 4. Altri tipi di commit
23
+ Esempi: chore:, docs:, test:, refactor:
24
+ Descrizione: Non triggerano una release di default, a meno che non siano configurati esplicitamente nel commit-analyzer.
25
+ Esempio: chore: aggiorna dipendenze
26
+
27
+ 5. Forzare una Release
28
+ Descrizione: Utile in caso di merge o altre operazioni.
29
+ Comandi:
30
+ git commit --allow-empty -m "feat: trigger test release"
31
+ Poi:
32
+ git push origin dev
33
+ Oppure:
34
+ git push origin main
@@ -8,5 +8,7 @@ export declare class EmailController {
8
8
  serveResetPasswordPage(res: Response, token: string, returnUrl?: string): Promise<void>;
9
9
  sendPasswordResetEmail(request: Request, sendResetPasswordData: {
10
10
  email: string;
11
+ resetUrlCustom?: string;
12
+ htmlMail?: string;
11
13
  }, res: Response): Promise<Response<any, Record<string, any>>>;
12
14
  }
@@ -41,7 +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
- yield this.emailService.sendPasswordResetEmail(sendResetPasswordData.email);
44
+ yield this.emailService.sendPasswordResetEmail(sendResetPasswordData.email, sendResetPasswordData.resetUrlCustom, sendResetPasswordData.htmlMail);
45
45
  return Utilities_1.RestUtilities.sendOKMessage(res, "L'email di reset è stata inoltrata al destinatario.");
46
46
  }
47
47
  catch (error) {
@@ -66,7 +66,22 @@ __decorate([
66
66
  ], EmailController.prototype, "serveResetPasswordPage", null);
67
67
  __decorate([
68
68
  (0, swagger_1.ApiOperation)({ summary: 'Invia una e-mail per il reset della password', operationId: "sendPasswordResetEmail" }),
69
- (0, swagger_1.ApiBody)({ schema: { properties: { email: { type: 'string', description: "L'email dell'utente che richiede il reset" } } } }),
69
+ (0, swagger_1.ApiBody)({ schema: { properties: {
70
+ email: {
71
+ type: 'string',
72
+ description: "L'email dell'utente che richiede il reset"
73
+ },
74
+ resetCustomUrl: {
75
+ type: 'string',
76
+ description: "Pagina di reset della password personalizzata",
77
+ },
78
+ htmlMail: {
79
+ type: 'string',
80
+ description: 'Corpo della mail in HTML'
81
+ }
82
+ },
83
+ required: ['email']
84
+ } }),
70
85
  (0, swagger_1.ApiResponse)({ status: 200, description: "L'email di reset è stata inviata con successo" }),
71
86
  (0, swagger_1.ApiResponse)({ status: 400, description: "Errore nella richiesta: protocollo o host non impostati" }),
72
87
  (0, swagger_1.ApiResponse)({ status: 500, description: "Errore interno durante l'invio dell'email" }),
@@ -1,9 +1,11 @@
1
1
  import { AccessiOptions } from '../../AccessiModule';
2
+ import { Logger } from '../../../Logger';
2
3
  export declare class EmailService {
3
4
  private readonly accessiOptions;
5
+ logger: Logger;
4
6
  constructor(accessiOptions: AccessiOptions);
5
7
  sendAccountUpdateEmail(email: string, message: string): Promise<void>;
6
8
  private transporter;
7
- sendPasswordResetEmail(email: string): Promise<void>;
9
+ sendPasswordResetEmail(email: string, resetUrlCustom?: string, htmlMail?: string): Promise<void>;
8
10
  private GetHtmlMail;
9
11
  }
@@ -23,6 +23,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
23
23
  var __importDefault = (this && this.__importDefault) || function (mod) {
24
24
  return (mod && mod.__esModule) ? mod : { "default": mod };
25
25
  };
26
+ var EmailService_1;
26
27
  Object.defineProperty(exports, "__esModule", { value: true });
27
28
  exports.EmailService = void 0;
28
29
  const nodemailer_1 = __importDefault(require("nodemailer"));
@@ -30,15 +31,17 @@ const uuid_1 = require("uuid");
30
31
  const Orm_1 = require("../../../Orm");
31
32
  const common_1 = require("@nestjs/common");
32
33
  const StatoRegistrazione_1 = require("../../Dtos/StatoRegistrazione");
33
- let EmailService = class EmailService {
34
+ const Logger_1 = require("../../../Logger");
35
+ let EmailService = EmailService_1 = class EmailService {
34
36
  constructor(accessiOptions) {
35
37
  this.accessiOptions = accessiOptions;
38
+ this.logger = new Logger_1.Logger(EmailService_1.name);
36
39
  this.transporter = nodemailer_1.default.createTransport(this.accessiOptions.emailOptions);
37
40
  }
38
41
  sendAccountUpdateEmail(email, message) {
39
42
  throw new Error('Method not implemented.');
40
43
  }
41
- sendPasswordResetEmail(email) {
44
+ sendPasswordResetEmail(email, resetUrlCustom, htmlMail) {
42
45
  return __awaiter(this, void 0, void 0, function* () {
43
46
  var _a;
44
47
  try {
@@ -50,9 +53,18 @@ let EmailService = class EmailService {
50
53
  }
51
54
  const returnUrlQueryParams = "?returnUrl=" + this.accessiOptions.confirmationEmailReturnUrl + "&prefix=" + ((_a = this.accessiOptions.confirmationEmailPrefix) !== null && _a !== void 0 ? _a : '');
52
55
  const { confirmationEmailUrl } = this.accessiOptions;
53
- const resetUrl = `${confirmationEmailUrl}/api/accessi/email/reset-password-page/${resetToken}${returnUrlQueryParams}`;
56
+ let resetUrl = `${confirmationEmailUrl}/api/accessi/email/reset-password-page/${resetToken}${returnUrlQueryParams}`;
57
+ if (resetUrlCustom) {
58
+ resetUrl = resetUrlCustom + "?token=" + resetToken;
59
+ this.logger.info('url personalizzato: ', resetUrl);
60
+ }
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,6 +76,7 @@ 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,
@@ -345,7 +358,7 @@ let EmailService = class EmailService {
345
358
  }
346
359
  };
347
360
  exports.EmailService = EmailService;
348
- exports.EmailService = EmailService = __decorate([
361
+ exports.EmailService = EmailService = EmailService_1 = __decorate([
349
362
  (0, common_1.Injectable)(),
350
363
  __param(0, (0, common_1.Inject)('ACCESSI_OPTIONS')),
351
364
  __metadata("design:paramtypes", [Object])
@@ -89,6 +89,7 @@ let UserService = class UserService {
89
89
  if (options.includeGrants)
90
90
  userGrants = yield this.permissionService.getUserRolesAndGrants(user.codiceUtente);
91
91
  let extensionFields = options.includeExtensionFields ? {} : null;
92
+ //todo: se non è prendente extensionFieldOptions va in errore. Risolvere il problema
92
93
  if (options.includeExtensionFields) {
93
94
  for (const ext of this.accessiOptions.extensionFieldsOptions) {
94
95
  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);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "emilsoftware-utilities",
3
- "version": "1.4.0-dev.1",
3
+ "version": "1.4.0-dev.3",
4
4
  "description": "Utilities for EmilSoftware",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",