emilsoftware-utilities 1.3.14 → 1.3.16
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 +17 -7
- package/dist/Orm.js +22 -9
- package/dist/Utilities.d.ts +21 -0
- package/dist/Utilities.js +73 -1
- package/dist/accessi-module/AccessiController.d.ts +10 -0
- package/dist/accessi-module/AccessiController.js +131 -0
- package/dist/accessi-module/AccessiModel.d.ts +72 -0
- package/dist/accessi-module/AccessiModel.js +422 -0
- package/dist/accessi-module/AccessiModule.d.ts +15 -0
- package/dist/accessi-module/AccessiModule.js +86 -0
- package/dist/accessi-module/AccessiRoutes.d.ts +9 -0
- package/dist/accessi-module/AccessiRoutes.js +81 -0
- package/dist/accessi-module/models/DTO/LoginRequest.d.ts +4 -0
- package/dist/accessi-module/models/DTO/LoginRequest.js +2 -0
- package/dist/accessi-module/models/DTO/LoginResponse.d.ts +6 -0
- package/dist/accessi-module/models/DTO/LoginResponse.js +2 -0
- package/dist/accessi-module/models/DTO/RegisterRequest.d.ts +14 -0
- package/dist/accessi-module/models/DTO/RegisterRequest.js +2 -0
- package/dist/accessi-module/models/JwtOptions.d.ts +4 -0
- package/dist/accessi-module/models/JwtOptions.js +9 -0
- package/dist/accessi-module/models/QueryResults/MenuAbilitazioniResult.d.ts +10 -0
- package/dist/accessi-module/models/QueryResults/MenuAbilitazioniResult.js +2 -0
- package/dist/accessi-module/models/QueryResults/UserQueryResult.d.ts +37 -0
- package/dist/accessi-module/models/QueryResults/UserQueryResult.js +2 -0
- package/dist/accessi-module/models/StatoRegistrazione.d.ts +8 -0
- package/dist/accessi-module/models/StatoRegistrazione.js +12 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +5 -2
- package/package.json +4 -1
- package/dist/Autobind.d.ts +0 -1
- package/dist/Autobind.js +0 -92
package/dist/Logger.js
CHANGED
|
@@ -26,13 +26,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
26
26
|
}) : function(o, v) {
|
|
27
27
|
o["default"] = v;
|
|
28
28
|
});
|
|
29
|
-
var __importStar = (this && this.__importStar) || function (
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
};
|
|
29
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
30
|
+
var ownKeys = function(o) {
|
|
31
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
32
|
+
var ar = [];
|
|
33
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
34
|
+
return ar;
|
|
35
|
+
};
|
|
36
|
+
return ownKeys(o);
|
|
37
|
+
};
|
|
38
|
+
return function (mod) {
|
|
39
|
+
if (mod && mod.__esModule) return mod;
|
|
40
|
+
var result = {};
|
|
41
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
42
|
+
__setModuleDefault(result, mod);
|
|
43
|
+
return result;
|
|
44
|
+
};
|
|
45
|
+
})();
|
|
36
46
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
37
47
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
38
48
|
return new (P || (P = Promise))(function (resolve, reject) {
|
package/dist/Orm.js
CHANGED
|
@@ -49,13 +49,23 @@ var __runInitializers = (this && this.__runInitializers) || function (thisArg, i
|
|
|
49
49
|
}
|
|
50
50
|
return useValue ? value : void 0;
|
|
51
51
|
};
|
|
52
|
-
var __importStar = (this && this.__importStar) || function (
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
};
|
|
52
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
53
|
+
var ownKeys = function(o) {
|
|
54
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
55
|
+
var ar = [];
|
|
56
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
57
|
+
return ar;
|
|
58
|
+
};
|
|
59
|
+
return ownKeys(o);
|
|
60
|
+
};
|
|
61
|
+
return function (mod) {
|
|
62
|
+
if (mod && mod.__esModule) return mod;
|
|
63
|
+
var result = {};
|
|
64
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
65
|
+
__setModuleDefault(result, mod);
|
|
66
|
+
return result;
|
|
67
|
+
};
|
|
68
|
+
})();
|
|
59
69
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
60
70
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
61
71
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -96,14 +106,17 @@ var __setFunctionName = (this && this.__setFunctionName) || function (f, name, p
|
|
|
96
106
|
if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
|
|
97
107
|
return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
|
|
98
108
|
};
|
|
109
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
110
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
111
|
+
};
|
|
99
112
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
100
113
|
exports.Orm = void 0;
|
|
101
114
|
var Firebird = __importStar(require("es-node-firebird"));
|
|
102
115
|
var Logger_1 = require("./Logger");
|
|
103
116
|
var Utilities_1 = require("./Utilities");
|
|
104
|
-
var
|
|
117
|
+
var autobind_decorator_1 = __importDefault(require("autobind-decorator"));
|
|
105
118
|
var Orm = function () {
|
|
106
|
-
var _classDecorators = [
|
|
119
|
+
var _classDecorators = [autobind_decorator_1.default];
|
|
107
120
|
var _classDescriptor;
|
|
108
121
|
var _classExtraInitializers = [];
|
|
109
122
|
var _classThis;
|
package/dist/Utilities.d.ts
CHANGED
|
@@ -84,6 +84,27 @@ export declare class RestUtilities {
|
|
|
84
84
|
* @returns The formatted query.
|
|
85
85
|
*/
|
|
86
86
|
static printQueryWithParams(query: string, params: any[]): string;
|
|
87
|
+
static convertKeysToCamelCase(obj: any): any;
|
|
88
|
+
}
|
|
89
|
+
export declare class CryptUtilities {
|
|
90
|
+
/**
|
|
91
|
+
* Cifra un testo in chiaro usando l'algoritmo AES-128 in modalità ECB.
|
|
92
|
+
*
|
|
93
|
+
* @param plainText - Il testo in chiaro da cifrare.
|
|
94
|
+
* @param key - La chiave di cifratura (16 byte per AES-128).
|
|
95
|
+
* @param outputEncoding - Codifica del risultato cifrato (predefinito: "base64").
|
|
96
|
+
* @returns Il testo cifrato codificato.
|
|
97
|
+
* @throws Errore in caso di problemi durante la cifratura.
|
|
98
|
+
*/
|
|
99
|
+
static encrypt(plainData: string, key: string, outputEncoding?: BufferEncoding): string;
|
|
100
|
+
/**
|
|
101
|
+
* Decifra un testo cifrato usando l'algoritmo AES-128 in modalità ECB.
|
|
102
|
+
*
|
|
103
|
+
* @param encryptedData - Il testo cifrato da decifrare.
|
|
104
|
+
* @param key - La chiave di decifratura (16 byte per AES-128).
|
|
105
|
+
* @returns Il testo decifrato o null in caso di errore.
|
|
106
|
+
*/
|
|
107
|
+
static decrypt(encryptedData: string, key: string): string | null;
|
|
87
108
|
}
|
|
88
109
|
/**
|
|
89
110
|
* Utility class for managing database-related configurations and operations.
|
package/dist/Utilities.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DatabaseUtilities = exports.RestUtilities = exports.DateUtilities = exports.StatusCode = void 0;
|
|
6
|
+
exports.DatabaseUtilities = exports.CryptUtilities = exports.RestUtilities = exports.DateUtilities = exports.StatusCode = void 0;
|
|
7
|
+
var crypto_1 = __importDefault(require("crypto"));
|
|
4
8
|
var StatusCode;
|
|
5
9
|
(function (StatusCode) {
|
|
6
10
|
StatusCode[StatusCode["Ok"] = 0] = "Ok";
|
|
@@ -194,9 +198,77 @@ var RestUtilities = /** @class */ (function () {
|
|
|
194
198
|
throw error;
|
|
195
199
|
}
|
|
196
200
|
};
|
|
201
|
+
RestUtilities.convertKeysToCamelCase = function (obj) {
|
|
202
|
+
if (obj !== null && obj.constructor === Object) {
|
|
203
|
+
return Object.keys(obj).reduce(function (acc, key) {
|
|
204
|
+
var camelCaseKey = key.toLowerCase().replace(/_([a-z])/g, function (g) { return g[1].toUpperCase(); });
|
|
205
|
+
acc[camelCaseKey] = obj[key];
|
|
206
|
+
return acc;
|
|
207
|
+
}, {});
|
|
208
|
+
}
|
|
209
|
+
return obj;
|
|
210
|
+
};
|
|
197
211
|
return RestUtilities;
|
|
198
212
|
}());
|
|
199
213
|
exports.RestUtilities = RestUtilities;
|
|
214
|
+
var CryptUtilities = /** @class */ (function () {
|
|
215
|
+
function CryptUtilities() {
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Cifra un testo in chiaro usando l'algoritmo AES-128 in modalità ECB.
|
|
219
|
+
*
|
|
220
|
+
* @param plainText - Il testo in chiaro da cifrare.
|
|
221
|
+
* @param key - La chiave di cifratura (16 byte per AES-128).
|
|
222
|
+
* @param outputEncoding - Codifica del risultato cifrato (predefinito: "base64").
|
|
223
|
+
* @returns Il testo cifrato codificato.
|
|
224
|
+
* @throws Errore in caso di problemi durante la cifratura.
|
|
225
|
+
*/
|
|
226
|
+
CryptUtilities.encrypt = function (plainData, key, outputEncoding) {
|
|
227
|
+
if (outputEncoding === void 0) { outputEncoding = "base64"; }
|
|
228
|
+
try {
|
|
229
|
+
// Crea un oggetto Cipher usando AES-128 in modalità ECB
|
|
230
|
+
var cipher = crypto_1.default.createCipheriv("aes-128-ecb", Buffer.from(key, "utf8"), null);
|
|
231
|
+
// Cifra il testo in chiaro e finalizza il processo
|
|
232
|
+
var encryptedBuffer = Buffer.concat([
|
|
233
|
+
cipher.update(plainData, "utf8"),
|
|
234
|
+
cipher.final(),
|
|
235
|
+
]);
|
|
236
|
+
// Restituisce il risultato cifrato codificato
|
|
237
|
+
return encryptedBuffer.toString(outputEncoding);
|
|
238
|
+
}
|
|
239
|
+
catch (error) {
|
|
240
|
+
// Gestisce eventuali errori di cifratura
|
|
241
|
+
throw new Error("Errore durante la cifratura: ".concat(error.message));
|
|
242
|
+
}
|
|
243
|
+
};
|
|
244
|
+
/**
|
|
245
|
+
* Decifra un testo cifrato usando l'algoritmo AES-128 in modalità ECB.
|
|
246
|
+
*
|
|
247
|
+
* @param encryptedData - Il testo cifrato da decifrare.
|
|
248
|
+
* @param key - La chiave di decifratura (16 byte per AES-128).
|
|
249
|
+
* @returns Il testo decifrato o null in caso di errore.
|
|
250
|
+
*/
|
|
251
|
+
CryptUtilities.decrypt = function (encryptedData, key) {
|
|
252
|
+
try {
|
|
253
|
+
// Crea un oggetto Decipher usando AES-128 in modalità ECB
|
|
254
|
+
var decipher = crypto_1.default.createDecipheriv("aes-128-ecb", Buffer.from(key, "utf8"), null);
|
|
255
|
+
decipher.setAutoPadding(false);
|
|
256
|
+
// Decifra il testo cifrato
|
|
257
|
+
var decoded = decipher.update(encryptedData, "base64", "utf8");
|
|
258
|
+
decoded += decipher.final("utf8");
|
|
259
|
+
// Rimuove il padding manuale
|
|
260
|
+
var lastChar = decoded.charCodeAt(decoded.length - 1);
|
|
261
|
+
decoded = decoded.slice(0, decoded.length - lastChar);
|
|
262
|
+
return decoded;
|
|
263
|
+
}
|
|
264
|
+
catch (error) {
|
|
265
|
+
console.error("Errore durante la decifratura:", error);
|
|
266
|
+
return null;
|
|
267
|
+
}
|
|
268
|
+
};
|
|
269
|
+
return CryptUtilities;
|
|
270
|
+
}());
|
|
271
|
+
exports.CryptUtilities = CryptUtilities;
|
|
200
272
|
/**
|
|
201
273
|
* Utility class for managing database-related configurations and operations.
|
|
202
274
|
*/
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { AccessiModel } from "./AccessiModel";
|
|
2
|
+
import { Response, Request } from "express";
|
|
3
|
+
import { JwtOptions } from "./models/JwtOptions";
|
|
4
|
+
export declare class AccessiController {
|
|
5
|
+
private accessiModel;
|
|
6
|
+
private jwtOptions;
|
|
7
|
+
private logger;
|
|
8
|
+
constructor(accessiModel: AccessiModel, jwtOptions: JwtOptions);
|
|
9
|
+
login(req: Request, res: Response): Promise<Response<any, Record<string, any>>>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
3
|
+
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
4
|
+
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
5
|
+
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
6
|
+
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
7
|
+
var _, done = false;
|
|
8
|
+
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
9
|
+
var context = {};
|
|
10
|
+
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
11
|
+
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
12
|
+
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
13
|
+
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
14
|
+
if (kind === "accessor") {
|
|
15
|
+
if (result === void 0) continue;
|
|
16
|
+
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
17
|
+
if (_ = accept(result.get)) descriptor.get = _;
|
|
18
|
+
if (_ = accept(result.set)) descriptor.set = _;
|
|
19
|
+
if (_ = accept(result.init)) initializers.unshift(_);
|
|
20
|
+
}
|
|
21
|
+
else if (_ = accept(result)) {
|
|
22
|
+
if (kind === "field") initializers.unshift(_);
|
|
23
|
+
else descriptor[key] = _;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
27
|
+
done = true;
|
|
28
|
+
};
|
|
29
|
+
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
30
|
+
var useValue = arguments.length > 2;
|
|
31
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
32
|
+
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
33
|
+
}
|
|
34
|
+
return useValue ? value : void 0;
|
|
35
|
+
};
|
|
36
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
37
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
38
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
39
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
40
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
41
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
42
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
46
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
47
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
48
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
49
|
+
function step(op) {
|
|
50
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
51
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
52
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
53
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
54
|
+
switch (op[0]) {
|
|
55
|
+
case 0: case 1: t = op; break;
|
|
56
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
57
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
58
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
59
|
+
default:
|
|
60
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
61
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
62
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
63
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
64
|
+
if (t[2]) _.ops.pop();
|
|
65
|
+
_.trys.pop(); continue;
|
|
66
|
+
}
|
|
67
|
+
op = body.call(thisArg, _);
|
|
68
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
69
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
|
|
73
|
+
if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
|
|
74
|
+
return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
|
|
75
|
+
};
|
|
76
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
77
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
78
|
+
};
|
|
79
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
80
|
+
exports.AccessiController = void 0;
|
|
81
|
+
var autobind_decorator_1 = __importDefault(require("autobind-decorator"));
|
|
82
|
+
var Logger_1 = require("../Logger");
|
|
83
|
+
var Utilities_1 = require("../Utilities");
|
|
84
|
+
var jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
|
|
85
|
+
var AccessiController = function () {
|
|
86
|
+
var _classDecorators = [autobind_decorator_1.default];
|
|
87
|
+
var _classDescriptor;
|
|
88
|
+
var _classExtraInitializers = [];
|
|
89
|
+
var _classThis;
|
|
90
|
+
var AccessiController = _classThis = /** @class */ (function () {
|
|
91
|
+
function AccessiController_1(accessiModel, jwtOptions) {
|
|
92
|
+
this.accessiModel = accessiModel;
|
|
93
|
+
this.jwtOptions = jwtOptions;
|
|
94
|
+
this.logger = new Logger_1.Logger(AccessiController.name);
|
|
95
|
+
}
|
|
96
|
+
AccessiController_1.prototype.login = function (req, res) {
|
|
97
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
98
|
+
var request, userData, token, error_1;
|
|
99
|
+
return __generator(this, function (_a) {
|
|
100
|
+
switch (_a.label) {
|
|
101
|
+
case 0:
|
|
102
|
+
_a.trys.push([0, 2, , 3]);
|
|
103
|
+
request = req.body;
|
|
104
|
+
return [4 /*yield*/, this.accessiModel.login(request)];
|
|
105
|
+
case 1:
|
|
106
|
+
userData = _a.sent();
|
|
107
|
+
if (!userData)
|
|
108
|
+
return [2 /*return*/, Utilities_1.RestUtilities.sendErrorMessage(res, "Credenziali errate", AccessiController.name)];
|
|
109
|
+
token = jsonwebtoken_1.default.sign({ userData: userData }, this.jwtOptions.secret, { expiresIn: this.jwtOptions.expiresIn });
|
|
110
|
+
return [2 /*return*/, Utilities_1.RestUtilities.sendBaseResponse(res, token)];
|
|
111
|
+
case 2:
|
|
112
|
+
error_1 = _a.sent();
|
|
113
|
+
return [2 /*return*/, Utilities_1.RestUtilities.sendErrorMessage(res, error_1, AccessiController.name)];
|
|
114
|
+
case 3: return [2 /*return*/];
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
};
|
|
119
|
+
return AccessiController_1;
|
|
120
|
+
}());
|
|
121
|
+
__setFunctionName(_classThis, "AccessiController");
|
|
122
|
+
(function () {
|
|
123
|
+
var _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
124
|
+
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
125
|
+
AccessiController = _classThis = _classDescriptor.value;
|
|
126
|
+
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
127
|
+
__runInitializers(_classThis, _classExtraInitializers);
|
|
128
|
+
})();
|
|
129
|
+
return AccessiController = _classThis;
|
|
130
|
+
}();
|
|
131
|
+
exports.AccessiController = AccessiController;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { Options } from "es-node-firebird";
|
|
2
|
+
import { LoginRequest } from "./models/DTO/LoginRequest";
|
|
3
|
+
import { LoginResponse } from "./models/DTO/LoginResponse";
|
|
4
|
+
import { StatoRegistrazione } from "./models/StatoRegistrazione";
|
|
5
|
+
import { RegisterRequest } from "./models/DTO/RegisterRequest";
|
|
6
|
+
export declare class AccessiModel {
|
|
7
|
+
private databaseOptions;
|
|
8
|
+
private encryptionKey;
|
|
9
|
+
private logger;
|
|
10
|
+
constructor(databaseOptions: Options, encryptionKey: string);
|
|
11
|
+
login(request: LoginRequest): Promise<LoginResponse>;
|
|
12
|
+
register(request: RegisterRequest): Promise<any>;
|
|
13
|
+
getCodiceUtenteByUsername(username: string): Promise<any>;
|
|
14
|
+
profiloLista(): Promise<any>;
|
|
15
|
+
resetAbilitazioni(codiceUtente: string): Promise<any>;
|
|
16
|
+
/**
|
|
17
|
+
*
|
|
18
|
+
|
|
19
|
+
public async addFiltri(params) {
|
|
20
|
+
try {
|
|
21
|
+
let iCodUte = params.codUte;
|
|
22
|
+
let iFiltro = params.filtro;
|
|
23
|
+
let sCodCli = params.codCli;
|
|
24
|
+
let iNumRep = params.numRep;
|
|
25
|
+
let iSuper = params.codSuper;
|
|
26
|
+
let iAgente = params.agente;
|
|
27
|
+
|
|
28
|
+
var sSql = "";
|
|
29
|
+
switch (iFiltro) {
|
|
30
|
+
case this.ID_TUTTICLIENTI: {
|
|
31
|
+
//uno o più clienti selezionati
|
|
32
|
+
sSql = "INSERT INTO FILTRI (CODUTE,TIPFIL) VALUES (";
|
|
33
|
+
sSql += iCodUte + "," + this.ID_TUTTICLIENTI.toString() + ")";
|
|
34
|
+
break;
|
|
35
|
+
}
|
|
36
|
+
case this.ID_SELCLIENTE: {
|
|
37
|
+
//uno o più clienti selezionati
|
|
38
|
+
sSql = "INSERT INTO FILTRI (CODUTE,CODCLIENTI,NUMREP,TIPFIL) VALUES (";
|
|
39
|
+
sSql += iCodUte + ",'" + sCodCli + "'," + iNumRep + "," + iFiltro + ")";
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
42
|
+
case this.ID_SELSUPER: {
|
|
43
|
+
//cliente padre
|
|
44
|
+
sSql = "INSERT INTO FILTRI (CODUTE,CODCLISUPER,TIPFIL) VALUES (";
|
|
45
|
+
sSql += iCodUte + "," + iSuper + "," + iFiltro + ")";
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
case this.ID_SELAGENTE: {
|
|
49
|
+
//agente
|
|
50
|
+
sSql = "INSERT INTO FILTRI (CODUTE,CODAGE,TIPFIL) VALUES (";
|
|
51
|
+
sSql += iCodUte + "," + iAgente + "," + iFiltro + ")";
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
default: {
|
|
55
|
+
//è un admin super utente
|
|
56
|
+
sSql = "INSERT INTO FILTRI (CODUTE,TIPFIL) VALUES (";
|
|
57
|
+
sSql += iCodUte + ",99)";
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
let result = await Orm.execute(optionsAccessi, sSql);
|
|
62
|
+
return result;
|
|
63
|
+
} catch (error) {
|
|
64
|
+
throw error;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
*/
|
|
68
|
+
setStatoRegistrazione(statoRegistrazione: StatoRegistrazione, codiceUtente: string): Promise<any>;
|
|
69
|
+
setGdpr(codiceUtente: string): Promise<any>;
|
|
70
|
+
addAbilitazioni(codiceUtente: string, menuAbilitazioni: any[]): Promise<void>;
|
|
71
|
+
setPassword(codiceUtente: string, nuovaPassword: string): Promise<any>;
|
|
72
|
+
}
|