emilsoftware-utilities 1.3.113 → 1.3.115
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/Logger.js
CHANGED
|
@@ -20,8 +20,9 @@ export interface EmailOptions {
|
|
|
20
20
|
pass: string;
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
|
-
export interface
|
|
23
|
+
export interface ExtensionFieldsOptions {
|
|
24
24
|
databaseOptions: Options;
|
|
25
|
+
objectKey: string;
|
|
25
26
|
tableName: string;
|
|
26
27
|
tableFields: string[];
|
|
27
28
|
tableJoinFieldName: string;
|
|
@@ -32,7 +33,7 @@ export interface AccessiOptions {
|
|
|
32
33
|
mockDemoUser: boolean;
|
|
33
34
|
jwtOptions: JwtOptions;
|
|
34
35
|
emailOptions: EmailOptions;
|
|
35
|
-
extensionFieldsOptions?:
|
|
36
|
+
extensionFieldsOptions?: ExtensionFieldsOptions[];
|
|
36
37
|
}
|
|
37
38
|
export declare class AccessiModule {
|
|
38
39
|
static forRoot(options: AccessiOptions): DynamicModule;
|
|
@@ -40,8 +40,8 @@ __decorate([
|
|
|
40
40
|
__metadata("design:type", UserGrantsDto_1.UserGrantsDto)
|
|
41
41
|
], LoginResult.prototype, "userGrants", void 0);
|
|
42
42
|
__decorate([
|
|
43
|
-
(0, swagger_1.ApiProperty)({ description: 'Extension Fields', type:
|
|
44
|
-
__metadata("design:type",
|
|
43
|
+
(0, swagger_1.ApiProperty)({ description: 'Extension Fields', type: Object }),
|
|
44
|
+
__metadata("design:type", Object)
|
|
45
45
|
], LoginResult.prototype, "extensionFields", void 0);
|
|
46
46
|
__decorate([
|
|
47
47
|
(0, swagger_1.ApiProperty)({ description: 'Token', type: TokenResult_1.TokenResult }),
|
|
@@ -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
|
// Recupera l'utente dal database
|
|
@@ -73,10 +75,11 @@ let AuthService = class AuthService {
|
|
|
73
75
|
const filtri = yield this.userService.getUserFilters(utente.codiceUtente);
|
|
74
76
|
const updateLastAccessDateQuery = "UPDATE UTENTI SET DATLASTLOGIN = CURRENT_TIMESTAMP WHERE CODUTE = ?";
|
|
75
77
|
yield Orm_1.Orm.query(this.accessiOptions.databaseOptions, updateLastAccessDateQuery, [utente.codiceUtente]);
|
|
76
|
-
|
|
77
|
-
this.accessiOptions.extensionFieldsOptions
|
|
78
|
-
|
|
79
|
-
|
|
78
|
+
let extensionFields = {};
|
|
79
|
+
for (const ext of this.accessiOptions.extensionFieldsOptions) {
|
|
80
|
+
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);
|
|
81
|
+
extensionFields[ext.objectKey] = values;
|
|
82
|
+
}
|
|
80
83
|
return { utente, filtri, userGrants, extensionFields };
|
|
81
84
|
});
|
|
82
85
|
}
|
|
@@ -85,7 +88,10 @@ let AuthService = class AuthService {
|
|
|
85
88
|
try {
|
|
86
89
|
const query = `UPDATE OR INSERT INTO UTENTI_PWD (CODUTE, PWD) VALUES (?, ?)`;
|
|
87
90
|
const hashedPassword = Utilities_1.CryptUtilities.encrypt(nuovaPassword, this.accessiOptions.encryptionKey);
|
|
88
|
-
return yield Orm_1.Orm.execute(this.accessiOptions.databaseOptions, query, [
|
|
91
|
+
return yield Orm_1.Orm.execute(this.accessiOptions.databaseOptions, query, [
|
|
92
|
+
codiceUtente,
|
|
93
|
+
hashedPassword,
|
|
94
|
+
]);
|
|
89
95
|
}
|
|
90
96
|
catch (error) {
|
|
91
97
|
throw error;
|
|
@@ -95,8 +101,7 @@ let AuthService = class AuthService {
|
|
|
95
101
|
verifyPassword(codiceUtente, passwordCifrata) {
|
|
96
102
|
return __awaiter(this, void 0, void 0, function* () {
|
|
97
103
|
const query = `SELECT PWD AS password FROM UTENTI_PWD WHERE CODUTE = ?`;
|
|
98
|
-
const result = yield Orm_1.Orm.query(this.accessiOptions.databaseOptions, query, [codiceUtente])
|
|
99
|
-
.then(results => results.map(Utilities_1.RestUtilities.convertKeysToCamelCase));
|
|
104
|
+
const result = (yield Orm_1.Orm.query(this.accessiOptions.databaseOptions, query, [codiceUtente]).then((results) => results.map(Utilities_1.RestUtilities.convertKeysToCamelCase)));
|
|
100
105
|
return result.length > 0 && result[0].password === passwordCifrata;
|
|
101
106
|
});
|
|
102
107
|
}
|
|
@@ -118,14 +123,14 @@ let AuthService = class AuthService {
|
|
|
118
123
|
flagSuper: true,
|
|
119
124
|
paginaDefault: "/home",
|
|
120
125
|
roles: [],
|
|
121
|
-
permissions: []
|
|
126
|
+
permissions: [],
|
|
122
127
|
},
|
|
123
128
|
filtri,
|
|
124
129
|
userGrants: {
|
|
125
130
|
abilitazioni: [],
|
|
126
131
|
grants: [],
|
|
127
|
-
ruoli: []
|
|
128
|
-
}
|
|
132
|
+
ruoli: [],
|
|
133
|
+
},
|
|
129
134
|
};
|
|
130
135
|
});
|
|
131
136
|
}
|
|
@@ -145,14 +150,14 @@ let AuthService = class AuthService {
|
|
|
145
150
|
flagSuper: false,
|
|
146
151
|
paginaDefault: "/home",
|
|
147
152
|
roles: [],
|
|
148
|
-
permissions: []
|
|
153
|
+
permissions: [],
|
|
149
154
|
},
|
|
150
155
|
filtri: null,
|
|
151
156
|
userGrants: {
|
|
152
157
|
abilitazioni: [],
|
|
153
158
|
grants: [],
|
|
154
|
-
ruoli: []
|
|
155
|
-
}
|
|
159
|
+
ruoli: [],
|
|
160
|
+
},
|
|
156
161
|
};
|
|
157
162
|
}
|
|
158
163
|
confirmResetPassword(token, newPassword) {
|
|
@@ -178,7 +183,7 @@ let AuthService = class AuthService {
|
|
|
178
183
|
exports.AuthService = AuthService;
|
|
179
184
|
exports.AuthService = AuthService = __decorate([
|
|
180
185
|
(0, common_1.Injectable)(),
|
|
181
|
-
__param(2, (0, common_1.Inject)(
|
|
186
|
+
__param(2, (0, common_1.Inject)("ACCESSI_OPTIONS")),
|
|
182
187
|
__metadata("design:paramtypes", [UserService_1.UserService,
|
|
183
188
|
PermissionService_1.PermissionService, Object])
|
|
184
189
|
], AuthService);
|