emilsoftware-utilities 1.4.0-dev.7 → 1.4.0-dev.9
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 +14 -3
- package/dist/accessi-module/Controllers/UserController.js +1 -1
- package/dist/accessi-module/Dtos/RegisterRequest.d.ts +3 -1
- package/dist/accessi-module/Dtos/RegisterRequest.js +85 -16
- package/dist/accessi-module/Services/AuthService/AuthService.js +17 -9
- package/dist/accessi-module/Services/EmailService/EmailService.js +1 -0
- package/dist/emilsoftware-utilities-1.4.0-dev.9.tgz +0 -0
- package/package.json +1 -1
- package/dist/emilsoftware-utilities-1.4.0-dev.7.tgz +0 -0
|
@@ -34,6 +34,7 @@ export interface AccessiOptions {
|
|
|
34
34
|
confirmationEmailPrefix?: string;
|
|
35
35
|
encryptionKey: string;
|
|
36
36
|
mockDemoUser: boolean;
|
|
37
|
+
passwordExpiration?: boolean;
|
|
37
38
|
jwtOptions: JwtOptions;
|
|
38
39
|
emailOptions: EmailOptions;
|
|
39
40
|
extensionFieldsOptions?: ExtensionFieldsOptions[];
|
|
@@ -23,7 +23,7 @@ let AccessiModule = AccessiModule_1 = class AccessiModule {
|
|
|
23
23
|
module: AccessiModule_1,
|
|
24
24
|
providers: [
|
|
25
25
|
{
|
|
26
|
-
provide:
|
|
26
|
+
provide: "ACCESSI_OPTIONS",
|
|
27
27
|
useValue: options,
|
|
28
28
|
},
|
|
29
29
|
AuthService_1.AuthService,
|
|
@@ -31,7 +31,13 @@ let AccessiModule = AccessiModule_1 = class AccessiModule {
|
|
|
31
31
|
EmailService_1.EmailService,
|
|
32
32
|
PermissionService_1.PermissionService,
|
|
33
33
|
],
|
|
34
|
-
exports: [
|
|
34
|
+
exports: [
|
|
35
|
+
"ACCESSI_OPTIONS",
|
|
36
|
+
AuthService_1.AuthService,
|
|
37
|
+
UserService_1.UserService,
|
|
38
|
+
EmailService_1.EmailService,
|
|
39
|
+
PermissionService_1.PermissionService,
|
|
40
|
+
],
|
|
35
41
|
};
|
|
36
42
|
}
|
|
37
43
|
};
|
|
@@ -39,7 +45,12 @@ exports.AccessiModule = AccessiModule;
|
|
|
39
45
|
exports.AccessiModule = AccessiModule = AccessiModule_1 = __decorate([
|
|
40
46
|
(0, common_1.Global)(),
|
|
41
47
|
(0, common_1.Module)({
|
|
42
|
-
controllers: [
|
|
48
|
+
controllers: [
|
|
49
|
+
EmailController_1.EmailController,
|
|
50
|
+
AuthController_1.AuthController,
|
|
51
|
+
PermissionController_1.PermissionController,
|
|
52
|
+
UserController_1.UserController,
|
|
53
|
+
],
|
|
43
54
|
providers: [AuthService_1.AuthService, UserService_1.UserService, EmailService_1.EmailService, PermissionService_1.PermissionService],
|
|
44
55
|
exports: [AuthService_1.AuthService, UserService_1.UserService, EmailService_1.EmailService, PermissionService_1.PermissionService],
|
|
45
56
|
})
|
|
@@ -77,7 +77,7 @@ let UserController = UserController_1 = class UserController {
|
|
|
77
77
|
return __awaiter(this, void 0, void 0, function* () {
|
|
78
78
|
try {
|
|
79
79
|
const codiceUtente = yield this.userService.register(registrationData);
|
|
80
|
-
yield this.emailService.sendPasswordResetEmail(registrationData.email);
|
|
80
|
+
yield this.emailService.sendPasswordResetEmail(registrationData.email, registrationData.resetUrlCustom, registrationData.htmlMail);
|
|
81
81
|
return Utilities_1.RestUtilities.sendBaseResponse(res, codiceUtente);
|
|
82
82
|
}
|
|
83
83
|
catch (error) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Permission } from
|
|
1
|
+
import { Permission } from "./Permission";
|
|
2
2
|
export declare class RegisterRequest {
|
|
3
3
|
email: string;
|
|
4
4
|
cognome?: string;
|
|
@@ -18,4 +18,6 @@ export declare class RegisterRequest {
|
|
|
18
18
|
flagDueFattori?: boolean;
|
|
19
19
|
paginaDefault?: string;
|
|
20
20
|
ragSocCli?: string;
|
|
21
|
+
resetUrlCustom?: string;
|
|
22
|
+
htmlMail?: string;
|
|
21
23
|
}
|
|
@@ -17,11 +17,17 @@ class RegisterRequest {
|
|
|
17
17
|
}
|
|
18
18
|
exports.RegisterRequest = RegisterRequest;
|
|
19
19
|
__decorate([
|
|
20
|
-
(0, swagger_1.ApiProperty)({
|
|
20
|
+
(0, swagger_1.ApiProperty)({
|
|
21
|
+
description: "Email dell'utente.",
|
|
22
|
+
example: "mario.rossi@dev.it",
|
|
23
|
+
}),
|
|
21
24
|
__metadata("design:type", String)
|
|
22
25
|
], RegisterRequest.prototype, "email", void 0);
|
|
23
26
|
__decorate([
|
|
24
|
-
(0, swagger_1.ApiPropertyOptional)({
|
|
27
|
+
(0, swagger_1.ApiPropertyOptional)({
|
|
28
|
+
description: "Cognome dell'utente.",
|
|
29
|
+
example: "Rossi",
|
|
30
|
+
}),
|
|
25
31
|
__metadata("design:type", String)
|
|
26
32
|
], RegisterRequest.prototype, "cognome", void 0);
|
|
27
33
|
__decorate([
|
|
@@ -29,7 +35,11 @@ __decorate([
|
|
|
29
35
|
__metadata("design:type", String)
|
|
30
36
|
], RegisterRequest.prototype, "nome", void 0);
|
|
31
37
|
__decorate([
|
|
32
|
-
(0, swagger_1.ApiPropertyOptional)({
|
|
38
|
+
(0, swagger_1.ApiPropertyOptional)({
|
|
39
|
+
description: "Numero di cellulare.",
|
|
40
|
+
example: "+393401234567",
|
|
41
|
+
nullable: true,
|
|
42
|
+
}),
|
|
33
43
|
__metadata("design:type", String)
|
|
34
44
|
], RegisterRequest.prototype, "cellulare", void 0);
|
|
35
45
|
__decorate([
|
|
@@ -37,54 +47,113 @@ __decorate([
|
|
|
37
47
|
__metadata("design:type", Boolean)
|
|
38
48
|
], RegisterRequest.prototype, "flagSuper", void 0);
|
|
39
49
|
__decorate([
|
|
40
|
-
(0, swagger_1.ApiPropertyOptional)({
|
|
50
|
+
(0, swagger_1.ApiPropertyOptional)({
|
|
51
|
+
description: "Ruoli assegnati all'utente.",
|
|
52
|
+
example: ["admin", "editor"],
|
|
53
|
+
}),
|
|
41
54
|
__metadata("design:type", Array)
|
|
42
55
|
], RegisterRequest.prototype, "roles", void 0);
|
|
43
56
|
__decorate([
|
|
44
|
-
(0, swagger_1.ApiPropertyOptional)({
|
|
57
|
+
(0, swagger_1.ApiPropertyOptional)({
|
|
58
|
+
description: "Permessi assegnati all'utente.",
|
|
59
|
+
type: [Permission_1.Permission],
|
|
60
|
+
example: [
|
|
61
|
+
{
|
|
62
|
+
codiceMenu: "MNUOFFICINA",
|
|
63
|
+
tipoAbilitazione: TipoAbilitazione_1.TipoAbilitazione.SCRITTURA,
|
|
64
|
+
},
|
|
65
|
+
],
|
|
66
|
+
}),
|
|
45
67
|
__metadata("design:type", Array)
|
|
46
68
|
], RegisterRequest.prototype, "permissions", void 0);
|
|
47
69
|
__decorate([
|
|
48
|
-
(0, swagger_1.ApiPropertyOptional)({
|
|
70
|
+
(0, swagger_1.ApiPropertyOptional)({
|
|
71
|
+
description: "Numero del report associato.",
|
|
72
|
+
example: 1002,
|
|
73
|
+
}),
|
|
49
74
|
__metadata("design:type", Number)
|
|
50
75
|
], RegisterRequest.prototype, "numeroReport", void 0);
|
|
51
76
|
__decorate([
|
|
52
|
-
(0, swagger_1.ApiPropertyOptional)({
|
|
77
|
+
(0, swagger_1.ApiPropertyOptional)({
|
|
78
|
+
description: "Indice personale dell'utente.",
|
|
79
|
+
example: 15,
|
|
80
|
+
}),
|
|
53
81
|
__metadata("design:type", Number)
|
|
54
82
|
], RegisterRequest.prototype, "indicePersonale", void 0);
|
|
55
83
|
__decorate([
|
|
56
|
-
(0, swagger_1.ApiPropertyOptional)({
|
|
84
|
+
(0, swagger_1.ApiPropertyOptional)({
|
|
85
|
+
description: "Codice del cliente principale (super).",
|
|
86
|
+
example: "CLT_SUP_1234",
|
|
87
|
+
}),
|
|
57
88
|
__metadata("design:type", String)
|
|
58
89
|
], RegisterRequest.prototype, "codiceClienteSuper", void 0);
|
|
59
90
|
__decorate([
|
|
60
|
-
(0, swagger_1.ApiPropertyOptional)({
|
|
91
|
+
(0, swagger_1.ApiPropertyOptional)({
|
|
92
|
+
description: "Codice dell'agenzia associata.",
|
|
93
|
+
example: "AGZ_5678",
|
|
94
|
+
}),
|
|
61
95
|
__metadata("design:type", String)
|
|
62
96
|
], RegisterRequest.prototype, "codiceAgenzia", void 0);
|
|
63
97
|
__decorate([
|
|
64
|
-
(0, swagger_1.ApiPropertyOptional)({
|
|
98
|
+
(0, swagger_1.ApiPropertyOptional)({
|
|
99
|
+
description: "Codice del cliente collegato.",
|
|
100
|
+
example: "CLT_COL_8765",
|
|
101
|
+
}),
|
|
65
102
|
__metadata("design:type", String)
|
|
66
103
|
], RegisterRequest.prototype, "codiceClienteCollegato", void 0);
|
|
67
104
|
__decorate([
|
|
68
|
-
(0, swagger_1.ApiPropertyOptional)({
|
|
105
|
+
(0, swagger_1.ApiPropertyOptional)({
|
|
106
|
+
description: "Lista di codici clienti separati da virgola.",
|
|
107
|
+
example: "CLT_123,CLT_456,CLT_789",
|
|
108
|
+
}),
|
|
69
109
|
__metadata("design:type", String)
|
|
70
110
|
], RegisterRequest.prototype, "codiceClienti", void 0);
|
|
71
111
|
__decorate([
|
|
72
|
-
(0, swagger_1.ApiPropertyOptional)({
|
|
112
|
+
(0, swagger_1.ApiPropertyOptional)({
|
|
113
|
+
description: "Tipo di filtro applicato.",
|
|
114
|
+
example: "esclusivo",
|
|
115
|
+
}),
|
|
73
116
|
__metadata("design:type", String)
|
|
74
117
|
], RegisterRequest.prototype, "tipoFiltro", void 0);
|
|
75
118
|
__decorate([
|
|
76
|
-
(0, swagger_1.ApiPropertyOptional)({
|
|
119
|
+
(0, swagger_1.ApiPropertyOptional)({
|
|
120
|
+
description: "Avatar dell'utente.",
|
|
121
|
+
example: "user.svg",
|
|
122
|
+
}),
|
|
77
123
|
__metadata("design:type", String)
|
|
78
124
|
], RegisterRequest.prototype, "avatar", void 0);
|
|
79
125
|
__decorate([
|
|
80
|
-
(0, swagger_1.ApiPropertyOptional)({
|
|
126
|
+
(0, swagger_1.ApiPropertyOptional)({
|
|
127
|
+
description: "Flag autenticazione a due fattori.",
|
|
128
|
+
example: false,
|
|
129
|
+
}),
|
|
81
130
|
__metadata("design:type", Boolean)
|
|
82
131
|
], RegisterRequest.prototype, "flagDueFattori", void 0);
|
|
83
132
|
__decorate([
|
|
84
|
-
(0, swagger_1.ApiPropertyOptional)({
|
|
133
|
+
(0, swagger_1.ApiPropertyOptional)({
|
|
134
|
+
description: "Pagina di default dell'utente.",
|
|
135
|
+
example: "/dashboard",
|
|
136
|
+
}),
|
|
85
137
|
__metadata("design:type", String)
|
|
86
138
|
], RegisterRequest.prototype, "paginaDefault", void 0);
|
|
87
139
|
__decorate([
|
|
88
|
-
(0, swagger_1.ApiPropertyOptional)({
|
|
140
|
+
(0, swagger_1.ApiPropertyOptional)({
|
|
141
|
+
description: "Ragione sociale cliente.",
|
|
142
|
+
example: "ALIVAL STOCK",
|
|
143
|
+
}),
|
|
89
144
|
__metadata("design:type", String)
|
|
90
145
|
], RegisterRequest.prototype, "ragSocCli", void 0);
|
|
146
|
+
__decorate([
|
|
147
|
+
(0, swagger_1.ApiPropertyOptional)({
|
|
148
|
+
description: "Link a una pagina di reset personalizzata",
|
|
149
|
+
example: "http://www.mio-progetto.it/reset-password",
|
|
150
|
+
}),
|
|
151
|
+
__metadata("design:type", String)
|
|
152
|
+
], RegisterRequest.prototype, "resetUrlCustom", void 0);
|
|
153
|
+
__decorate([
|
|
154
|
+
(0, swagger_1.ApiPropertyOptional)({
|
|
155
|
+
description: "HTML mail personalizzato",
|
|
156
|
+
example: "<html></html>",
|
|
157
|
+
}),
|
|
158
|
+
__metadata("design:type", String)
|
|
159
|
+
], RegisterRequest.prototype, "htmlMail", void 0);
|
|
@@ -36,9 +36,11 @@ let AuthService = class AuthService {
|
|
|
36
36
|
}
|
|
37
37
|
login(request) {
|
|
38
38
|
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
-
if (this.accessiOptions.mockDemoUser &&
|
|
39
|
+
if (this.accessiOptions.mockDemoUser &&
|
|
40
|
+
request.email.toLowerCase() === "demo")
|
|
40
41
|
return this.getDemoUser();
|
|
41
|
-
if (this.accessiOptions.mockDemoUser &&
|
|
42
|
+
if (this.accessiOptions.mockDemoUser &&
|
|
43
|
+
request.email.toLowerCase() === "admin")
|
|
42
44
|
return this.getAdminUser();
|
|
43
45
|
const passwordCifrata = Utilities_1.CryptUtilities.encrypt(request.password, this.accessiOptions.encryptionKey);
|
|
44
46
|
const utente = yield this.userService.getUserByEmail(request.email.toLowerCase());
|
|
@@ -61,10 +63,13 @@ let AuthService = class AuthService {
|
|
|
61
63
|
const isPasswordValid = yield this.verifyPassword(utente.codiceUtente, passwordCifrata);
|
|
62
64
|
if (!isPasswordValid)
|
|
63
65
|
throw new Error("Nome utente o password errata!");
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
if (this.accessiOptions.passwordExpiration &&
|
|
67
|
+
this.accessiOptions.passwordExpiration == true) {
|
|
68
|
+
const today = new Date();
|
|
69
|
+
const targetDate = new Date(utente.dataScadenzaPassword);
|
|
70
|
+
if (today >= targetDate) {
|
|
71
|
+
throw new Error("PASSWORD_EXPIRED");
|
|
72
|
+
}
|
|
68
73
|
}
|
|
69
74
|
// Recupera i grants
|
|
70
75
|
const userGrants = yield this.permissionService.getUserRolesAndGrants(utente.codiceUtente);
|
|
@@ -73,9 +78,12 @@ let AuthService = class AuthService {
|
|
|
73
78
|
const updateLastAccessDateQuery = "UPDATE UTENTI SET DATLASTLOGIN = CURRENT_TIMESTAMP WHERE CODUTE = ?";
|
|
74
79
|
yield Orm_1.Orm.query(this.accessiOptions.databaseOptions, updateLastAccessDateQuery, [utente.codiceUtente]);
|
|
75
80
|
let extensionFields = {};
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
81
|
+
if (this.accessiOptions.extensionFieldsOptions &&
|
|
82
|
+
this.accessiOptions.extensionFieldsOptions.length > 0) {
|
|
83
|
+
for (const ext of this.accessiOptions.extensionFieldsOptions) {
|
|
84
|
+
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);
|
|
85
|
+
extensionFields[ext.objectKey] = values;
|
|
86
|
+
}
|
|
79
87
|
}
|
|
80
88
|
return { utente, filtri, userGrants, extensionFields };
|
|
81
89
|
});
|
|
@@ -53,6 +53,7 @@ let EmailService = class EmailService {
|
|
|
53
53
|
resetUrl = resetUrlCustom + "?token=" + resetToken;
|
|
54
54
|
}
|
|
55
55
|
let sPhrase;
|
|
56
|
+
console.log('reset_url', resetUrlCustom);
|
|
56
57
|
if (htmlMail) {
|
|
57
58
|
sPhrase = htmlMail;
|
|
58
59
|
sPhrase.replace('#link_conferma_password_url', resetUrl);
|
|
Binary file
|
package/package.json
CHANGED
|
Binary file
|