emilsoftware-utilities 1.3.71 → 1.3.73
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 +2 -29
- package/dist/accessi-module/AccessiModule.js +35 -43
- package/dist/accessi-module/Controllers/AccessiController.d.ts +28 -49
- package/dist/accessi-module/Controllers/AccessiController.js +179 -95
- package/dist/accessi-module/Services/AuthService/AuthService.d.ts +4 -4
- package/dist/accessi-module/Services/AuthService/AuthService.js +7 -6
- package/dist/accessi-module/Services/EmailService/EmailService.d.ts +1 -1
- package/dist/accessi-module/Services/EmailService/EmailService.js +3 -3
- package/dist/accessi-module/Services/PermissionService/PermissionService.d.ts +1 -1
- package/dist/accessi-module/Services/PermissionService/PermissionService.js +3 -3
- package/dist/accessi-module/Services/UserService/UserService.d.ts +1 -1
- package/dist/accessi-module/Services/UserService/UserService.js +3 -2
- package/dist/accessi-module/index.d.ts +3 -0
- package/dist/accessi-module/index.js +23 -2
- package/dist/accessi-module/swagger/SwaggerConfig.d.ts +2 -1
- package/dist/accessi-module/swagger/SwaggerConfig.js +9 -29
- package/package.json +7 -2
- package/dist/accessi-module/Controllers/AccessiControllerBase.d.ts +0 -387
- package/dist/accessi-module/Controllers/AccessiControllerBase.js +0 -11
- package/dist/accessi-module/IAccessiRoutes.d.ts +0 -5
- package/dist/accessi-module/IAccessiRoutes.js +0 -2
- package/dist/accessi-module/Routes/AccessiRoutes.d.ts +0 -10
- package/dist/accessi-module/Routes/AccessiRoutes.js +0 -55
- package/dist/accessi-module/inversify.config.d.ts +0 -3
- package/dist/accessi-module/inversify.config.js +0 -65
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* @author mttdev382
|
|
6
6
|
*/
|
|
7
7
|
import { Options } from "es-node-firebird";
|
|
8
|
-
import {
|
|
8
|
+
import { DynamicModule } from "@nestjs/common";
|
|
9
9
|
export interface JwtOptions {
|
|
10
10
|
secret: string;
|
|
11
11
|
expiresIn: string;
|
|
@@ -28,32 +28,5 @@ export interface AccessiOptions {
|
|
|
28
28
|
emailOptions: EmailOptions;
|
|
29
29
|
}
|
|
30
30
|
export declare class AccessiModule {
|
|
31
|
-
|
|
32
|
-
private logger;
|
|
33
|
-
private accessiRoutes;
|
|
34
|
-
/**
|
|
35
|
-
* Crea una nuova istanza del modulo Accessi.
|
|
36
|
-
*
|
|
37
|
-
* @param {Options} databaseOptions - Le opzioni di configurazione per la connessione al database.
|
|
38
|
-
* @param {string} encryptionKey - La chiave di cifratura per la gestione dei dati sensibili.
|
|
39
|
-
* @param {JwtOptions} jwtOptions - Le opzioni per la gestione dei token JWT.
|
|
40
|
-
* @author mttdev382
|
|
41
|
-
|
|
42
|
-
*/
|
|
43
|
-
constructor(app: Application, options: AccessiOptions);
|
|
44
|
-
/**
|
|
45
|
-
* Ottiene il router delle rotte per gestire gli accessi.
|
|
46
|
-
*
|
|
47
|
-
* **Consiglio:** È consigliabile utilizzare questo router nel primo livello della tua applicazione (es. /api/accessi).
|
|
48
|
-
* @deprecated A breve questo metodo sparirà, la libreria viene importata automaticamente.
|
|
49
|
-
* @returns {Router} Il router con le rotte degli accessi.
|
|
50
|
-
* @author mttdev382
|
|
51
|
-
*/
|
|
52
|
-
getAccessiRouter(): Router;
|
|
53
|
-
/**
|
|
54
|
-
* Inizializza la documentazione di swagger per gli accessi.
|
|
55
|
-
* @deprecated A breve questo metodo sparirà, la libreria servirà swagger autonomamente.
|
|
56
|
-
* @author mttdev382
|
|
57
|
-
*/
|
|
58
|
-
serveSwaggerDocs(app: Application): void;
|
|
31
|
+
static forRoot(options: AccessiOptions): DynamicModule;
|
|
59
32
|
}
|
|
@@ -1,48 +1,40 @@
|
|
|
1
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 AccessiModule_1;
|
|
2
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
10
|
exports.AccessiModule = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
11
|
+
const common_1 = require("@nestjs/common");
|
|
12
|
+
const AccessiController_1 = require("./Controllers/AccessiController");
|
|
13
|
+
const AuthService_1 = require("./Services/AuthService/AuthService");
|
|
14
|
+
const EmailService_1 = require("./Services/EmailService/EmailService");
|
|
15
|
+
const PermissionService_1 = require("./Services/PermissionService/PermissionService");
|
|
16
|
+
const UserService_1 = require("./Services/UserService/UserService");
|
|
17
|
+
let AccessiModule = AccessiModule_1 = class AccessiModule {
|
|
18
|
+
static forRoot(options) {
|
|
19
|
+
return {
|
|
20
|
+
module: AccessiModule_1,
|
|
21
|
+
controllers: [AccessiController_1.AccessiController],
|
|
22
|
+
providers: [
|
|
23
|
+
{
|
|
24
|
+
provide: 'ACCESSI_OPTIONS',
|
|
25
|
+
useValue: options,
|
|
26
|
+
},
|
|
27
|
+
UserService_1.UserService,
|
|
28
|
+
AuthService_1.AuthService,
|
|
29
|
+
EmailService_1.EmailService,
|
|
30
|
+
PermissionService_1.PermissionService,
|
|
31
|
+
],
|
|
32
|
+
exports: ['ACCESSI_OPTIONS', AuthService_1.AuthService, UserService_1.UserService, EmailService_1.EmailService, PermissionService_1.PermissionService], // Esportiamo AuthService per altri moduli
|
|
33
|
+
};
|
|
26
34
|
}
|
|
27
|
-
|
|
28
|
-
* Ottiene il router delle rotte per gestire gli accessi.
|
|
29
|
-
*
|
|
30
|
-
* **Consiglio:** È consigliabile utilizzare questo router nel primo livello della tua applicazione (es. /api/accessi).
|
|
31
|
-
* @deprecated A breve questo metodo sparirà, la libreria viene importata automaticamente.
|
|
32
|
-
* @returns {Router} Il router con le rotte degli accessi.
|
|
33
|
-
* @author mttdev382
|
|
34
|
-
*/
|
|
35
|
-
getAccessiRouter() {
|
|
36
|
-
this.logger.info(`Importazione delle rotte di 'ACCESSI', è consigliabile utilizzarle nel primo livello della tua applicazione (es. /api/accessi).`);
|
|
37
|
-
return this.accessiRoutes.router;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Inizializza la documentazione di swagger per gli accessi.
|
|
41
|
-
* @deprecated A breve questo metodo sparirà, la libreria servirà swagger autonomamente.
|
|
42
|
-
* @author mttdev382
|
|
43
|
-
*/
|
|
44
|
-
serveSwaggerDocs(app) {
|
|
45
|
-
(0, SwaggerConfig_1.serveSwaggerDocs)(app);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
35
|
+
};
|
|
48
36
|
exports.AccessiModule = AccessiModule;
|
|
37
|
+
exports.AccessiModule = AccessiModule = AccessiModule_1 = __decorate([
|
|
38
|
+
(0, common_1.Global)(),
|
|
39
|
+
(0, common_1.Module)({})
|
|
40
|
+
], AccessiModule);
|
|
@@ -1,52 +1,31 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
encrypt(req: Request<{}, {}, {
|
|
27
|
-
data: string;
|
|
28
|
-
}>, res: Response): Promise<Response<any, Record<string, any>>>;
|
|
29
|
-
decrypt(req: Request<{}, {}, {
|
|
30
|
-
data: string;
|
|
31
|
-
}>, res: Response): Promise<Response<any, Record<string, any>>>;
|
|
32
|
-
resetAbilitazioni(req: Request<{}, {}, {
|
|
33
|
-
codiceUtente: string;
|
|
34
|
-
}>, res: Response): Promise<Response<any, Record<string, any>>>;
|
|
35
|
-
setPassword(req: Request<{}, {}, {
|
|
1
|
+
import { Response } from 'express';
|
|
2
|
+
import { AccessiOptions } from '../AccessiModule';
|
|
3
|
+
import { AuthService } from '../Services/AuthService/AuthService';
|
|
4
|
+
import { PermissionService } from '../Services/PermissionService/PermissionService';
|
|
5
|
+
import { UserService } from '../Services/UserService/UserService';
|
|
6
|
+
import { EmailService } from '../Services/EmailService/EmailService';
|
|
7
|
+
export declare class AccessiController {
|
|
8
|
+
private readonly userService;
|
|
9
|
+
private readonly authService;
|
|
10
|
+
private readonly emailService;
|
|
11
|
+
private readonly permissionService;
|
|
12
|
+
private readonly options;
|
|
13
|
+
constructor(userService: UserService, authService: AuthService, emailService: EmailService, permissionService: PermissionService, options: AccessiOptions);
|
|
14
|
+
getUserByToken(token: string, res: Response): Promise<Response<any, Record<string, any>>>;
|
|
15
|
+
login(loginDto: {
|
|
16
|
+
username: string;
|
|
17
|
+
password: string;
|
|
18
|
+
}, res: Response): Promise<Response<any, Record<string, any>>>;
|
|
19
|
+
getUsers(res: Response): Promise<Response<any, Record<string, any>>>;
|
|
20
|
+
deleteUser(codiceUtente: string, res: Response): Promise<Response<any, Record<string, any>>>;
|
|
21
|
+
register(request: any, res: Response): Promise<Response<any, Record<string, any>>>;
|
|
22
|
+
encrypt(data: string, res: Response): Promise<Response<any, Record<string, any>>>;
|
|
23
|
+
decrypt(data: string, res: Response): Promise<Response<any, Record<string, any>>>;
|
|
24
|
+
resetAbilitazioni(codiceUtente: string, res: Response): Promise<Response<any, Record<string, any>>>;
|
|
25
|
+
setPassword(request: {
|
|
36
26
|
codiceUtente: string;
|
|
37
27
|
nuovaPassword: string;
|
|
38
|
-
}
|
|
39
|
-
updateUtente(
|
|
40
|
-
setGdpr(
|
|
41
|
-
codiceUtente: string;
|
|
42
|
-
}>, res: Response): Promise<Response<any, Record<string, any>>>;
|
|
43
|
-
verifyEmail(req: Request<{
|
|
44
|
-
token: string;
|
|
45
|
-
}>, res: Response): Promise<Response<any, Record<string, any>>>;
|
|
46
|
-
requestPasswordReset(req: Request, res: Response): Promise<Response<any, Record<string, any>>>;
|
|
47
|
-
resetPassword(req: Request<{
|
|
48
|
-
token: string;
|
|
49
|
-
}, {}, {
|
|
50
|
-
newPassword: string;
|
|
51
|
-
}>, res: Response): Promise<Response<any, Record<string, any>>>;
|
|
28
|
+
}, res: Response): Promise<Response<any, Record<string, any>>>;
|
|
29
|
+
updateUtente(user: any, res: Response): Promise<Response<any, Record<string, any>>>;
|
|
30
|
+
setGdpr(codiceUtente: string, res: Response): Promise<Response<any, Record<string, any>>>;
|
|
52
31
|
}
|
|
@@ -1,10 +1,43 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
2
18
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
19
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
20
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
21
|
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
22
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
23
|
};
|
|
24
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
+
var ownKeys = function(o) {
|
|
26
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
+
var ar = [];
|
|
28
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
+
return ar;
|
|
30
|
+
};
|
|
31
|
+
return ownKeys(o);
|
|
32
|
+
};
|
|
33
|
+
return function (mod) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
+
__setModuleDefault(result, mod);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
})();
|
|
8
41
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
42
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
43
|
};
|
|
@@ -20,40 +53,33 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
20
53
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
21
54
|
});
|
|
22
55
|
};
|
|
23
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
24
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
25
|
-
};
|
|
26
56
|
var AccessiController_1;
|
|
27
57
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
58
|
exports.AccessiController = void 0;
|
|
29
|
-
const
|
|
30
|
-
const
|
|
59
|
+
const common_1 = require("@nestjs/common");
|
|
60
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
61
|
+
const jwt = __importStar(require("jsonwebtoken"));
|
|
31
62
|
const Utilities_1 = require("../../Utilities");
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
*/
|
|
63
|
+
const AuthService_1 = require("../Services/AuthService/AuthService");
|
|
64
|
+
const PermissionService_1 = require("../Services/PermissionService/PermissionService");
|
|
65
|
+
const UserService_1 = require("../Services/UserService/UserService");
|
|
66
|
+
const EmailService_1 = require("../Services/EmailService/EmailService");
|
|
37
67
|
let AccessiController = AccessiController_1 = class AccessiController {
|
|
38
|
-
constructor(userService,
|
|
68
|
+
constructor(userService, authService, emailService, permissionService, options) {
|
|
39
69
|
this.userService = userService;
|
|
40
|
-
this.permissionService = permissionService;
|
|
41
70
|
this.authService = authService;
|
|
42
71
|
this.emailService = emailService;
|
|
43
|
-
this.
|
|
72
|
+
this.permissionService = permissionService;
|
|
73
|
+
this.options = options;
|
|
44
74
|
}
|
|
45
|
-
getUserByToken(
|
|
75
|
+
getUserByToken(token, res) {
|
|
46
76
|
return __awaiter(this, void 0, void 0, function* () {
|
|
47
77
|
try {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
// Decodifica il token JWT
|
|
53
|
-
const decoded = jsonwebtoken_1.default.verify(token, this.accessiOptions.jwtOptions.secret);
|
|
54
|
-
if (!decoded) {
|
|
78
|
+
if (!token)
|
|
79
|
+
return Utilities_1.RestUtilities.sendErrorMessage(res, 'Token non fornito', AccessiController_1.name);
|
|
80
|
+
const decoded = jwt.verify(token, this.options.jwtOptions.secret);
|
|
81
|
+
if (!decoded)
|
|
55
82
|
return Utilities_1.RestUtilities.sendUnauthorized(res);
|
|
56
|
-
}
|
|
57
83
|
return Utilities_1.RestUtilities.sendBaseResponse(res, { userData: decoded });
|
|
58
84
|
}
|
|
59
85
|
catch (error) {
|
|
@@ -61,17 +87,16 @@ let AccessiController = AccessiController_1 = class AccessiController {
|
|
|
61
87
|
}
|
|
62
88
|
});
|
|
63
89
|
}
|
|
64
|
-
login(
|
|
90
|
+
login(loginDto, res) {
|
|
65
91
|
return __awaiter(this, void 0, void 0, function* () {
|
|
66
92
|
try {
|
|
67
|
-
|
|
68
|
-
const userData = yield this.authService.login(request);
|
|
93
|
+
const userData = yield this.authService.login(loginDto);
|
|
69
94
|
if (!userData)
|
|
70
95
|
return Utilities_1.RestUtilities.sendInvalidCredentials(res);
|
|
71
96
|
userData.token = {
|
|
72
|
-
expiresIn: this.
|
|
73
|
-
value:
|
|
74
|
-
type:
|
|
97
|
+
expiresIn: this.options.jwtOptions.expiresIn,
|
|
98
|
+
value: jwt.sign({ userData }, this.options.jwtOptions.secret, { expiresIn: this.options.jwtOptions.expiresIn }),
|
|
99
|
+
type: 'Bearer',
|
|
75
100
|
};
|
|
76
101
|
return Utilities_1.RestUtilities.sendBaseResponse(res, userData);
|
|
77
102
|
}
|
|
@@ -80,7 +105,7 @@ let AccessiController = AccessiController_1 = class AccessiController {
|
|
|
80
105
|
}
|
|
81
106
|
});
|
|
82
107
|
}
|
|
83
|
-
getUsers(
|
|
108
|
+
getUsers(res) {
|
|
84
109
|
return __awaiter(this, void 0, void 0, function* () {
|
|
85
110
|
try {
|
|
86
111
|
const users = yield this.userService.getUsers();
|
|
@@ -91,38 +116,34 @@ let AccessiController = AccessiController_1 = class AccessiController {
|
|
|
91
116
|
}
|
|
92
117
|
});
|
|
93
118
|
}
|
|
94
|
-
deleteUser(
|
|
119
|
+
deleteUser(codiceUtente, res) {
|
|
95
120
|
return __awaiter(this, void 0, void 0, function* () {
|
|
96
121
|
try {
|
|
97
|
-
|
|
98
|
-
if (!codiceUtente) {
|
|
122
|
+
if (!codiceUtente)
|
|
99
123
|
throw new Error('Il campo "Codice Utente" è obbligatorio.');
|
|
100
|
-
}
|
|
101
124
|
yield this.userService.deleteUser(codiceUtente);
|
|
102
|
-
return Utilities_1.RestUtilities.sendOKMessage(res,
|
|
125
|
+
return Utilities_1.RestUtilities.sendOKMessage(res, 'L\'utente è stato eliminato con successo.');
|
|
103
126
|
}
|
|
104
127
|
catch (error) {
|
|
105
128
|
return Utilities_1.RestUtilities.sendErrorMessage(res, error);
|
|
106
129
|
}
|
|
107
130
|
});
|
|
108
131
|
}
|
|
109
|
-
register(
|
|
132
|
+
register(request, res) {
|
|
110
133
|
return __awaiter(this, void 0, void 0, function* () {
|
|
111
134
|
try {
|
|
112
|
-
let request = req.body;
|
|
113
135
|
yield this.userService.register(request);
|
|
114
|
-
return Utilities_1.RestUtilities.sendOKMessage(res,
|
|
136
|
+
return Utilities_1.RestUtilities.sendOKMessage(res, 'L\'utente è stato registrato con successo.');
|
|
115
137
|
}
|
|
116
138
|
catch (error) {
|
|
117
139
|
return Utilities_1.RestUtilities.sendErrorMessage(res, error, AccessiController_1.name);
|
|
118
140
|
}
|
|
119
141
|
});
|
|
120
142
|
}
|
|
121
|
-
encrypt(
|
|
143
|
+
encrypt(data, res) {
|
|
122
144
|
return __awaiter(this, void 0, void 0, function* () {
|
|
123
145
|
try {
|
|
124
|
-
const
|
|
125
|
-
let encryptedData = Utilities_1.CryptUtilities.encrypt(req.body.data, key);
|
|
146
|
+
const encryptedData = Utilities_1.CryptUtilities.encrypt(data, this.options.encryptionKey);
|
|
126
147
|
return Utilities_1.RestUtilities.sendBaseResponse(res, encryptedData);
|
|
127
148
|
}
|
|
128
149
|
catch (error) {
|
|
@@ -130,11 +151,10 @@ let AccessiController = AccessiController_1 = class AccessiController {
|
|
|
130
151
|
}
|
|
131
152
|
});
|
|
132
153
|
}
|
|
133
|
-
decrypt(
|
|
154
|
+
decrypt(data, res) {
|
|
134
155
|
return __awaiter(this, void 0, void 0, function* () {
|
|
135
156
|
try {
|
|
136
|
-
const
|
|
137
|
-
let decryptedData = Utilities_1.CryptUtilities.decrypt(req.body.data, key);
|
|
157
|
+
const decryptedData = Utilities_1.CryptUtilities.decrypt(data, this.options.encryptionKey);
|
|
138
158
|
return Utilities_1.RestUtilities.sendBaseResponse(res, decryptedData);
|
|
139
159
|
}
|
|
140
160
|
catch (error) {
|
|
@@ -142,78 +162,44 @@ let AccessiController = AccessiController_1 = class AccessiController {
|
|
|
142
162
|
}
|
|
143
163
|
});
|
|
144
164
|
}
|
|
145
|
-
resetAbilitazioni(
|
|
165
|
+
resetAbilitazioni(codiceUtente, res) {
|
|
146
166
|
return __awaiter(this, void 0, void 0, function* () {
|
|
147
167
|
try {
|
|
148
|
-
yield this.permissionService.resetAbilitazioni(
|
|
149
|
-
return Utilities_1.RestUtilities.sendOKMessage(res, `Le abilitazioni dell'utente ${
|
|
168
|
+
yield this.permissionService.resetAbilitazioni(codiceUtente);
|
|
169
|
+
return Utilities_1.RestUtilities.sendOKMessage(res, `Le abilitazioni dell'utente ${codiceUtente} sono state resettate con successo.`);
|
|
150
170
|
}
|
|
151
171
|
catch (error) {
|
|
152
172
|
return Utilities_1.RestUtilities.sendErrorMessage(res, error, AccessiController_1.name);
|
|
153
173
|
}
|
|
154
174
|
});
|
|
155
175
|
}
|
|
156
|
-
setPassword(
|
|
176
|
+
setPassword(request, res) {
|
|
157
177
|
return __awaiter(this, void 0, void 0, function* () {
|
|
158
178
|
try {
|
|
159
|
-
yield this.authService.setPassword(
|
|
160
|
-
return Utilities_1.RestUtilities.sendOKMessage(res, `La password dell'utente ${
|
|
179
|
+
yield this.authService.setPassword(request.codiceUtente, request.nuovaPassword);
|
|
180
|
+
return Utilities_1.RestUtilities.sendOKMessage(res, `La password dell'utente ${request.codiceUtente} è stata impostata correttamente.`);
|
|
161
181
|
}
|
|
162
182
|
catch (error) {
|
|
163
183
|
return Utilities_1.RestUtilities.sendErrorMessage(res, error, AccessiController_1.name);
|
|
164
184
|
}
|
|
165
185
|
});
|
|
166
186
|
}
|
|
167
|
-
updateUtente(
|
|
187
|
+
updateUtente(user, res) {
|
|
168
188
|
return __awaiter(this, void 0, void 0, function* () {
|
|
169
189
|
try {
|
|
170
|
-
let user = req.body;
|
|
171
190
|
yield this.userService.updateUser(user);
|
|
172
|
-
return Utilities_1.RestUtilities.sendOKMessage(res, `L'utente ${
|
|
173
|
-
}
|
|
174
|
-
catch (error) {
|
|
175
|
-
return Utilities_1.RestUtilities.sendErrorMessage(res, error, AccessiController_1.name);
|
|
176
|
-
}
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
setGdpr(req, res) {
|
|
180
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
181
|
-
try {
|
|
182
|
-
yield this.userService.setGdpr(req.body.codiceUtente);
|
|
183
|
-
return Utilities_1.RestUtilities.sendOKMessage(res, `L'utente ${req.body.codiceUtente} ha accettato il GDRP.`);
|
|
184
|
-
}
|
|
185
|
-
catch (error) {
|
|
186
|
-
return Utilities_1.RestUtilities.sendErrorMessage(res, error, AccessiController_1.name);
|
|
187
|
-
}
|
|
188
|
-
});
|
|
189
|
-
}
|
|
190
|
-
verifyEmail(req, res) {
|
|
191
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
192
|
-
try {
|
|
193
|
-
yield this.userService.verifyEmail(req.params.token);
|
|
194
|
-
return Utilities_1.RestUtilities.sendOKMessage(res, "Email verificata con successo!");
|
|
195
|
-
}
|
|
196
|
-
catch (error) {
|
|
197
|
-
return Utilities_1.RestUtilities.sendErrorMessage(res, error, AccessiController_1.name);
|
|
198
|
-
}
|
|
199
|
-
});
|
|
200
|
-
}
|
|
201
|
-
requestPasswordReset(req, res) {
|
|
202
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
203
|
-
try {
|
|
204
|
-
yield this.emailService.sendPasswordResetEmail(req.body.email, req.headers.origin);
|
|
205
|
-
return Utilities_1.RestUtilities.sendOKMessage(res, "Email di reset inviata!");
|
|
191
|
+
return Utilities_1.RestUtilities.sendOKMessage(res, `L'utente ${user.codiceUtente} è stato aggiornato con successo.`);
|
|
206
192
|
}
|
|
207
193
|
catch (error) {
|
|
208
194
|
return Utilities_1.RestUtilities.sendErrorMessage(res, error, AccessiController_1.name);
|
|
209
195
|
}
|
|
210
196
|
});
|
|
211
197
|
}
|
|
212
|
-
|
|
198
|
+
setGdpr(codiceUtente, res) {
|
|
213
199
|
return __awaiter(this, void 0, void 0, function* () {
|
|
214
200
|
try {
|
|
215
|
-
yield this.
|
|
216
|
-
return Utilities_1.RestUtilities.sendOKMessage(res,
|
|
201
|
+
yield this.userService.setGdpr(codiceUtente);
|
|
202
|
+
return Utilities_1.RestUtilities.sendOKMessage(res, `L'utente ${codiceUtente} ha accettato il GDPR.`);
|
|
217
203
|
}
|
|
218
204
|
catch (error) {
|
|
219
205
|
return Utilities_1.RestUtilities.sendErrorMessage(res, error, AccessiController_1.name);
|
|
@@ -222,12 +208,110 @@ let AccessiController = AccessiController_1 = class AccessiController {
|
|
|
222
208
|
}
|
|
223
209
|
};
|
|
224
210
|
exports.AccessiController = AccessiController;
|
|
211
|
+
__decorate([
|
|
212
|
+
(0, swagger_1.ApiOperation)({ summary: 'Recupera le informazioni utente dal token JWT' }),
|
|
213
|
+
(0, common_1.Post)('get-user-by-token'),
|
|
214
|
+
__param(0, (0, common_1.Body)('token')),
|
|
215
|
+
__param(1, (0, common_1.Res)()),
|
|
216
|
+
__metadata("design:type", Function),
|
|
217
|
+
__metadata("design:paramtypes", [String, Object]),
|
|
218
|
+
__metadata("design:returntype", Promise)
|
|
219
|
+
], AccessiController.prototype, "getUserByToken", null);
|
|
220
|
+
__decorate([
|
|
221
|
+
(0, swagger_1.ApiOperation)({ summary: 'Effettua il login' }),
|
|
222
|
+
(0, common_1.Post)('login'),
|
|
223
|
+
__param(0, (0, common_1.Body)()),
|
|
224
|
+
__param(1, (0, common_1.Res)()),
|
|
225
|
+
__metadata("design:type", Function),
|
|
226
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
227
|
+
__metadata("design:returntype", Promise)
|
|
228
|
+
], AccessiController.prototype, "login", null);
|
|
229
|
+
__decorate([
|
|
230
|
+
(0, swagger_1.ApiOperation)({ summary: 'Recupera la lista degli utenti' }),
|
|
231
|
+
(0, common_1.Get)('users'),
|
|
232
|
+
__param(0, (0, common_1.Res)()),
|
|
233
|
+
__metadata("design:type", Function),
|
|
234
|
+
__metadata("design:paramtypes", [Object]),
|
|
235
|
+
__metadata("design:returntype", Promise)
|
|
236
|
+
], AccessiController.prototype, "getUsers", null);
|
|
237
|
+
__decorate([
|
|
238
|
+
(0, swagger_1.ApiOperation)({ summary: 'Elimina un utente' }),
|
|
239
|
+
(0, common_1.Post)('delete-user'),
|
|
240
|
+
__param(0, (0, common_1.Body)('codiceUtente')),
|
|
241
|
+
__param(1, (0, common_1.Res)()),
|
|
242
|
+
__metadata("design:type", Function),
|
|
243
|
+
__metadata("design:paramtypes", [String, Object]),
|
|
244
|
+
__metadata("design:returntype", Promise)
|
|
245
|
+
], AccessiController.prototype, "deleteUser", null);
|
|
246
|
+
__decorate([
|
|
247
|
+
(0, swagger_1.ApiOperation)({ summary: 'Registra un nuovo utente' }),
|
|
248
|
+
(0, common_1.Post)('register'),
|
|
249
|
+
__param(0, (0, common_1.Body)()),
|
|
250
|
+
__param(1, (0, common_1.Res)()),
|
|
251
|
+
__metadata("design:type", Function),
|
|
252
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
253
|
+
__metadata("design:returntype", Promise)
|
|
254
|
+
], AccessiController.prototype, "register", null);
|
|
255
|
+
__decorate([
|
|
256
|
+
(0, swagger_1.ApiOperation)({ summary: 'Crittografa i dati' }),
|
|
257
|
+
(0, common_1.Post)('encrypt'),
|
|
258
|
+
__param(0, (0, common_1.Body)('data')),
|
|
259
|
+
__param(1, (0, common_1.Res)()),
|
|
260
|
+
__metadata("design:type", Function),
|
|
261
|
+
__metadata("design:paramtypes", [String, Object]),
|
|
262
|
+
__metadata("design:returntype", Promise)
|
|
263
|
+
], AccessiController.prototype, "encrypt", null);
|
|
264
|
+
__decorate([
|
|
265
|
+
(0, swagger_1.ApiOperation)({ summary: 'Decrittografa i dati' }),
|
|
266
|
+
(0, common_1.Post)('decrypt'),
|
|
267
|
+
__param(0, (0, common_1.Body)('data')),
|
|
268
|
+
__param(1, (0, common_1.Res)()),
|
|
269
|
+
__metadata("design:type", Function),
|
|
270
|
+
__metadata("design:paramtypes", [String, Object]),
|
|
271
|
+
__metadata("design:returntype", Promise)
|
|
272
|
+
], AccessiController.prototype, "decrypt", null);
|
|
273
|
+
__decorate([
|
|
274
|
+
(0, swagger_1.ApiOperation)({ summary: 'Resetta le abilitazioni di un utente' }),
|
|
275
|
+
(0, common_1.Post)('reset-abilitazioni'),
|
|
276
|
+
__param(0, (0, common_1.Body)('codiceUtente')),
|
|
277
|
+
__param(1, (0, common_1.Res)()),
|
|
278
|
+
__metadata("design:type", Function),
|
|
279
|
+
__metadata("design:paramtypes", [String, Object]),
|
|
280
|
+
__metadata("design:returntype", Promise)
|
|
281
|
+
], AccessiController.prototype, "resetAbilitazioni", null);
|
|
282
|
+
__decorate([
|
|
283
|
+
(0, swagger_1.ApiOperation)({ summary: 'Imposta una nuova password' }),
|
|
284
|
+
(0, common_1.Post)('set-password'),
|
|
285
|
+
__param(0, (0, common_1.Body)()),
|
|
286
|
+
__param(1, (0, common_1.Res)()),
|
|
287
|
+
__metadata("design:type", Function),
|
|
288
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
289
|
+
__metadata("design:returntype", Promise)
|
|
290
|
+
], AccessiController.prototype, "setPassword", null);
|
|
291
|
+
__decorate([
|
|
292
|
+
(0, swagger_1.ApiOperation)({ summary: 'Aggiorna un utente esistente' }),
|
|
293
|
+
(0, common_1.Post)('update-utente'),
|
|
294
|
+
__param(0, (0, common_1.Body)()),
|
|
295
|
+
__param(1, (0, common_1.Res)()),
|
|
296
|
+
__metadata("design:type", Function),
|
|
297
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
298
|
+
__metadata("design:returntype", Promise)
|
|
299
|
+
], AccessiController.prototype, "updateUtente", null);
|
|
300
|
+
__decorate([
|
|
301
|
+
(0, swagger_1.ApiOperation)({ summary: 'Imposta il consenso GDPR' }),
|
|
302
|
+
(0, common_1.Post)('set-gdpr'),
|
|
303
|
+
__param(0, (0, common_1.Body)('codiceUtente')),
|
|
304
|
+
__param(1, (0, common_1.Res)()),
|
|
305
|
+
__metadata("design:type", Function),
|
|
306
|
+
__metadata("design:paramtypes", [String, Object]),
|
|
307
|
+
__metadata("design:returntype", Promise)
|
|
308
|
+
], AccessiController.prototype, "setGdpr", null);
|
|
225
309
|
exports.AccessiController = AccessiController = AccessiController_1 = __decorate([
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
__param(
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
310
|
+
(0, swagger_1.ApiTags)('Accessi'),
|
|
311
|
+
(0, common_1.Controller)('accessi'),
|
|
312
|
+
__param(4, (0, common_1.Inject)('ACCESSI_OPTIONS')),
|
|
313
|
+
__metadata("design:paramtypes", [UserService_1.UserService,
|
|
314
|
+
AuthService_1.AuthService,
|
|
315
|
+
EmailService_1.EmailService,
|
|
316
|
+
PermissionService_1.PermissionService, Object])
|
|
233
317
|
], AccessiController);
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { AccessiOptions } from "../../AccessiModule";
|
|
2
2
|
import { IAuthService, ILoginResult, LoginRequest } from "./IAuthService";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { UserService } from "../UserService/UserService";
|
|
4
|
+
import { PermissionService } from "../PermissionService/PermissionService";
|
|
5
5
|
export declare class AuthService implements IAuthService {
|
|
6
6
|
private userService;
|
|
7
7
|
private permissionService;
|
|
8
|
-
private accessiOptions;
|
|
9
|
-
constructor(userService:
|
|
8
|
+
private readonly accessiOptions;
|
|
9
|
+
constructor(userService: UserService, permissionService: PermissionService, accessiOptions: AccessiOptions);
|
|
10
10
|
login(request: LoginRequest): Promise<ILoginResult>;
|
|
11
11
|
setPassword(codiceUtente: string, nuovaPassword: string): Promise<any>;
|
|
12
12
|
verifyPassword(codiceUtente: string, passwordCifrata: string): Promise<boolean>;
|