emilsoftware-utilities 2.0.0-dev.2 → 2.0.0-dev.21
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 +38 -38
- package/dist/ContractGenerator.js.map +1 -1
- package/dist/DatabaseUpdater.d.ts +1 -1
- package/dist/DatabaseUpdater.js +24 -24
- package/dist/DatabaseUpdater.js.map +1 -1
- package/dist/EmilsoftwareModule.js.map +1 -1
- package/dist/ExecutionTimeLogger.js.map +1 -1
- package/dist/Logger.js.map +1 -1
- package/dist/Orm.d.ts +7 -1
- package/dist/Orm.js +172 -78
- package/dist/Orm.js.map +1 -1
- package/dist/RoutesLoggerMiddleware.js.map +1 -1
- package/dist/Utilities.d.ts +2 -2
- package/dist/Utilities.js +3 -0
- package/dist/Utilities.js.map +1 -1
- package/dist/accessi-module/AccessiModule.d.ts +1 -1
- package/dist/accessi-module/AccessiModule.js.map +1 -1
- package/dist/accessi-module/Controllers/AuthController.d.ts +4 -4
- package/dist/accessi-module/Controllers/AuthController.js +43 -33
- package/dist/accessi-module/Controllers/AuthController.js.map +1 -1
- package/dist/accessi-module/Controllers/ConfiguratorController.js +25 -30
- package/dist/accessi-module/Controllers/ConfiguratorController.js.map +1 -1
- package/dist/accessi-module/Controllers/EmailController.d.ts +2 -4
- package/dist/accessi-module/Controllers/EmailController.js +8 -12
- package/dist/accessi-module/Controllers/EmailController.js.map +1 -1
- package/dist/accessi-module/Controllers/FiltriController.js +29 -0
- package/dist/accessi-module/Controllers/FiltriController.js.map +1 -1
- package/dist/accessi-module/Controllers/PermissionController.js +35 -33
- package/dist/accessi-module/Controllers/PermissionController.js.map +1 -1
- package/dist/accessi-module/Controllers/UserController.d.ts +2 -2
- package/dist/accessi-module/Controllers/UserController.js +30 -12
- package/dist/accessi-module/Controllers/UserController.js.map +1 -1
- package/dist/accessi-module/Dtos/Abilitazione.js.map +1 -1
- package/dist/accessi-module/Dtos/AbilitazioneMenu.js.map +1 -1
- package/dist/accessi-module/Dtos/AssignPermissionsToUserRequest.js +0 -1
- package/dist/accessi-module/Dtos/AssignPermissionsToUserRequest.js.map +1 -1
- package/dist/accessi-module/Dtos/AssignRolesToUserRequest.js +0 -1
- package/dist/accessi-module/Dtos/AssignRolesToUserRequest.js.map +1 -1
- package/dist/accessi-module/Dtos/AuthenticatedUserPayloadDto.d.ts +10 -0
- package/dist/accessi-module/Dtos/AuthenticatedUserPayloadDto.js +52 -0
- package/dist/accessi-module/Dtos/AuthenticatedUserPayloadDto.js.map +1 -0
- package/dist/accessi-module/Dtos/BaseResponse.d.ts +20 -0
- package/dist/accessi-module/Dtos/BaseResponse.js +87 -1
- package/dist/accessi-module/Dtos/BaseResponse.js.map +1 -1
- package/dist/accessi-module/Dtos/ConfirmResetPasswordRequest.d.ts +3 -0
- package/dist/accessi-module/Dtos/ConfirmResetPasswordRequest.js +31 -0
- package/dist/accessi-module/Dtos/ConfirmResetPasswordRequest.js.map +1 -0
- package/dist/accessi-module/Dtos/FiltriUtente.js +1 -0
- package/dist/accessi-module/Dtos/FiltriUtente.js.map +1 -1
- package/dist/accessi-module/Dtos/GetGroupsWithMenusResponse.js.map +1 -1
- package/dist/accessi-module/Dtos/GetMenusResponse.js.map +1 -1
- package/dist/accessi-module/Dtos/GetRolesResponse.js.map +1 -1
- package/dist/accessi-module/Dtos/GetUserByTokenRequest.d.ts +3 -0
- package/dist/accessi-module/Dtos/GetUserByTokenRequest.js +26 -0
- package/dist/accessi-module/Dtos/GetUserByTokenRequest.js.map +1 -0
- package/dist/accessi-module/Dtos/GetUserByTokenResponse.d.ts +5 -0
- package/dist/accessi-module/Dtos/GetUserByTokenResponse.js +27 -0
- package/dist/accessi-module/Dtos/GetUserByTokenResponse.js.map +1 -0
- package/dist/accessi-module/Dtos/GetUsersResponse.js.map +1 -1
- package/dist/accessi-module/Dtos/LoginRequest.js.map +1 -1
- package/dist/accessi-module/Dtos/LoginResponse.js.map +1 -1
- package/dist/accessi-module/Dtos/Permission.js.map +1 -1
- package/dist/accessi-module/Dtos/PublicRegisterRequest.d.ts +5 -0
- package/dist/accessi-module/Dtos/PublicRegisterRequest.js +14 -0
- package/dist/accessi-module/Dtos/PublicRegisterRequest.js.map +1 -0
- package/dist/accessi-module/Dtos/RegisterRequest.js +4 -0
- package/dist/accessi-module/Dtos/RegisterRequest.js.map +1 -1
- package/dist/accessi-module/Dtos/RegisterResponse.d.ts +1 -1
- package/dist/accessi-module/Dtos/RegisterResponse.js +3 -3
- package/dist/accessi-module/Dtos/RegisterResponse.js.map +1 -1
- package/dist/accessi-module/Dtos/Role.js.map +1 -1
- package/dist/accessi-module/Dtos/RuoliMenu.js.map +1 -1
- package/dist/accessi-module/Dtos/SendResetPasswordEmailRequest.d.ts +4 -0
- package/dist/accessi-module/Dtos/SendResetPasswordEmailRequest.js +36 -0
- package/dist/accessi-module/Dtos/SendResetPasswordEmailRequest.js.map +1 -0
- package/dist/accessi-module/Dtos/SetStatoRegistrazione.js.map +1 -1
- package/dist/accessi-module/Dtos/StatoRegistrazione.js.map +1 -1
- package/dist/accessi-module/Dtos/TipoAbilitazione.js.map +1 -1
- package/dist/accessi-module/Dtos/TipoFiltro.js.map +1 -1
- package/dist/accessi-module/Dtos/TokenResult.js.map +1 -1
- package/dist/accessi-module/Dtos/UpdateEnabledStatusRequest.js.map +1 -1
- package/dist/accessi-module/Dtos/UserDto.js +5 -1
- package/dist/accessi-module/Dtos/UserDto.js.map +1 -1
- package/dist/accessi-module/Dtos/UserGrantsDto.js.map +1 -1
- package/dist/accessi-module/Dtos/UserGrantsResponse.d.ts +5 -0
- package/dist/accessi-module/Dtos/UserGrantsResponse.js +27 -0
- package/dist/accessi-module/Dtos/UserGrantsResponse.js.map +1 -0
- package/dist/accessi-module/Dtos/index.d.ts +7 -0
- package/dist/accessi-module/Dtos/index.js +7 -0
- package/dist/accessi-module/Dtos/index.js.map +1 -1
- package/dist/accessi-module/Services/AuthService/AuthService.js.map +1 -1
- package/dist/accessi-module/Services/ConfiguratorService/ConfiguratorService.js.map +1 -1
- package/dist/accessi-module/Services/EmailService/EmailService.js +11 -11
- package/dist/accessi-module/Services/EmailService/EmailService.js.map +1 -1
- package/dist/accessi-module/Services/FiltriService/FiltriService.js +1 -8
- package/dist/accessi-module/Services/FiltriService/FiltriService.js.map +1 -1
- package/dist/accessi-module/Services/PermissionService/PermissionService.d.ts +4 -0
- package/dist/accessi-module/Services/PermissionService/PermissionService.js +210 -147
- package/dist/accessi-module/Services/PermissionService/PermissionService.js.map +1 -1
- package/dist/accessi-module/Services/UserService/UserService.js +77 -174
- package/dist/accessi-module/Services/UserService/UserService.js.map +1 -1
- package/dist/accessi-module/Views/reset-password.html +213 -213
- package/dist/accessi-module/database-updates/AccessiDatabaseUpdater.js +16 -16
- package/dist/accessi-module/database-updates/AccessiDatabaseUpdater.js.map +1 -1
- package/dist/accessi-module/database-updates/runAccessiDbUpdate.js.map +1 -1
- package/dist/accessi-module/index.d.ts +1 -0
- package/dist/accessi-module/index.js +28 -5
- package/dist/accessi-module/index.js.map +1 -1
- package/dist/accessi-module/jwt/jwt.strategy.js.map +1 -1
- package/dist/accessi-module/middleware/accessiRequirements.js.map +1 -1
- package/dist/accessi-module/middleware/authenticateGen.js.map +1 -1
- package/dist/accessi-module/security/accessControl.js.map +1 -1
- package/dist/accessi-module/security/authenticatedToken.js.map +1 -1
- package/dist/accessi-module/security/passwordResetToken.js.map +1 -1
- package/dist/accessi-module/security/publicAuthRateLimit.js.map +1 -1
- package/dist/allegati-module/AllegatiModule.d.ts +1 -1
- package/dist/allegati-module/AllegatiModule.js.map +1 -1
- package/dist/allegati-module/Controllers/AllegatiController.js.map +1 -1
- package/dist/allegati-module/Dtos/AllegatoDto.js.map +1 -1
- package/dist/allegati-module/Dtos/BaseResponse.js.map +1 -1
- package/dist/allegati-module/Dtos/UploadSingleFileRequest.js.map +1 -1
- package/dist/allegati-module/Dtos/index.js.map +1 -1
- package/dist/allegati-module/Dtos/responses/DownloadAllegatoResponseDto.js.map +1 -1
- package/dist/allegati-module/Dtos/responses/GetListResponse.js.map +1 -1
- package/dist/allegati-module/Dtos/responses/UploadAllegatoResponseDto.js.map +1 -1
- package/dist/allegati-module/Services/AllegatiService/AllegatiService.js +49 -49
- package/dist/allegati-module/Services/AllegatiService/AllegatiService.js.map +1 -1
- package/dist/allegati-module/index.js.map +1 -1
- package/dist/autobind.js.map +1 -1
- package/dist/emilsoftware-utilities-2.0.0-dev.21.tgz +0 -0
- package/dist/firebird-compat.d.ts +25 -0
- package/dist/firebird-compat.js +218 -0
- package/dist/firebird-compat.js.map +1 -0
- package/dist/index.d.ts +5 -2
- package/dist/index.js +28 -2
- package/dist/index.js.map +1 -1
- package/dist/initEmilsoftwareModule.js.map +1 -1
- package/dist/swagger/SwaggerConfig.d.ts +7 -1
- package/dist/swagger/SwaggerConfig.js +18 -7
- package/dist/swagger/SwaggerConfig.js.map +1 -1
- package/package.json +83 -83
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AccessiModule.js","sourceRoot":"","sources":["../../src/accessi-module/AccessiModule.ts"],"names":[],"mappings":";;;;;;;;;;AAOA,2CAA+D;AAC/D,oEAAiE;AACjE,uEAAoE;AACpE,sFAAmF;AACnF,oEAAiE;AACjE,mEAAgE;AAChE,iEAA8D;AAC9D,6EAA0E;AAC1E,iEAA8D;AAC9D,0EAAuE;AACvE,qEAAkE;AAClE,iFAA8E;AAC9E,4FAAyF;AACzF,qDAAoD;AACpD,kEAAsE;AACtE,sFAAmF;AAkF5E,IAAM,aAAa,qBAAnB,MAAM,aAAa;IACxB,MAAM,CAAC,OAAO,CAAC,OAAuB;QACpC,OAAO;YACL,MAAM,EAAE,eAAa;YACrB,SAAS,EAAE;gBACT;oBACE,OAAO,EAAE,iBAAiB;oBAC1B,QAAQ,EAAE,OAAO;iBAClB;gBACD,yBAAW;gBACX,yBAAW;gBACX,2BAAY;gBACZ,qCAAiB;gBACjB,6BAAa;gBACb,yCAAmB;gBACnB,6BAAc;gBACd,wCAAsB;gBACtB,+CAAsB;aACvB;YACD,OAAO,EAAE;gBACP,iBAAiB;gBACjB,yBAAW;gBACX,yBAAW;gBACX,2BAAY;gBACZ,qCAAiB;gBACjB,6BAAa;gBACb,yCAAmB;gBACnB,6BAAc;gBACd,wCAAsB;aACvB;SACF,CAAC;IACJ,CAAC;CACF,CAAA;AAhCY,sCAAa;wBAAb,aAAa;IAbzB,IAAA,eAAM,GAAE;IACR,IAAA,eAAM,EAAC;QACN,WAAW,EAAE;YACX,iCAAe;YACf,+BAAc;YACd,2CAAoB;YACpB,+BAAc;YACd,mCAAgB;YAChB,+CAAsB;SACvB;QACD,SAAS,EAAE,CAAC,yBAAW,EAAE,yBAAW,EAAE,2BAAY,EAAE,qCAAiB,EAAE,6BAAa,EAAE,yCAAmB,EAAE,6BAAc,EAAE,wCAAsB,EAAE,+CAAsB,CAAC;QAC1K,OAAO,EAAE,CAAC,yBAAW,EAAE,yBAAW,EAAE,2BAAY,EAAE,qCAAiB,EAAE,6BAAa,EAAE,yCAAmB,EAAE,6BAAc,EAAE,wCAAsB,CAAC;KACjJ,CAAC;GACW,aAAa,CAgCzB","sourcesContent":["/**\
|
|
1
|
+
{"version":3,"file":"AccessiModule.js","sourceRoot":"","sources":["../../src/accessi-module/AccessiModule.ts"],"names":[],"mappings":";;;;;;;;;;AAOA,2CAA+D;AAC/D,oEAAiE;AACjE,uEAAoE;AACpE,sFAAmF;AACnF,oEAAiE;AACjE,mEAAgE;AAChE,iEAA8D;AAC9D,6EAA0E;AAC1E,iEAA8D;AAC9D,0EAAuE;AACvE,qEAAkE;AAClE,iFAA8E;AAC9E,4FAAyF;AACzF,qDAAoD;AACpD,kEAAsE;AACtE,sFAAmF;AAkF5E,IAAM,aAAa,qBAAnB,MAAM,aAAa;IACxB,MAAM,CAAC,OAAO,CAAC,OAAuB;QACpC,OAAO;YACL,MAAM,EAAE,eAAa;YACrB,SAAS,EAAE;gBACT;oBACE,OAAO,EAAE,iBAAiB;oBAC1B,QAAQ,EAAE,OAAO;iBAClB;gBACD,yBAAW;gBACX,yBAAW;gBACX,2BAAY;gBACZ,qCAAiB;gBACjB,6BAAa;gBACb,yCAAmB;gBACnB,6BAAc;gBACd,wCAAsB;gBACtB,+CAAsB;aACvB;YACD,OAAO,EAAE;gBACP,iBAAiB;gBACjB,yBAAW;gBACX,yBAAW;gBACX,2BAAY;gBACZ,qCAAiB;gBACjB,6BAAa;gBACb,yCAAmB;gBACnB,6BAAc;gBACd,wCAAsB;aACvB;SACF,CAAC;IACJ,CAAC;CACF,CAAA;AAhCY,sCAAa;wBAAb,aAAa;IAbzB,IAAA,eAAM,GAAE;IACR,IAAA,eAAM,EAAC;QACN,WAAW,EAAE;YACX,iCAAe;YACf,+BAAc;YACd,2CAAoB;YACpB,+BAAc;YACd,mCAAgB;YAChB,+CAAsB;SACvB;QACD,SAAS,EAAE,CAAC,yBAAW,EAAE,yBAAW,EAAE,2BAAY,EAAE,qCAAiB,EAAE,6BAAa,EAAE,yCAAmB,EAAE,6BAAc,EAAE,wCAAsB,EAAE,+CAAsB,CAAC;QAC1K,OAAO,EAAE,CAAC,yBAAW,EAAE,yBAAW,EAAE,2BAAY,EAAE,qCAAiB,EAAE,6BAAa,EAAE,yCAAmB,EAAE,6BAAc,EAAE,wCAAsB,CAAC;KACjJ,CAAC;GACW,aAAa,CAgCzB","sourcesContent":["/**\n * Modulo che gestisce le operazioni di accesso degli utenti, incluse le rotte, il controller e il modello.\n *\n * @module AccessiModule\n * @author mttdev382\n */\nimport { Options } from 'node-firebird';\nimport { DynamicModule, Global, Module } from '@nestjs/common';\nimport { AuthService } from './Services/AuthService/AuthService';\nimport { EmailService } from './Services/EmailService/EmailService';\nimport { PermissionService } from './Services/PermissionService/PermissionService';\nimport { UserService } from './Services/UserService/UserService';\nimport { EmailController } from './Controllers/EmailController';\nimport { AuthController } from './Controllers/AuthController';\nimport { PermissionController } from './Controllers/PermissionController';\nimport { UserController } from './Controllers/UserController';\nimport { FiltriService } from './Services/FiltriService/FiltriService';\nimport { FiltriController } from './Controllers/FiltriController';\nimport { ConfiguratorController } from './Controllers/ConfiguratorController';\nimport { ConfiguratorService } from './Services/ConfiguratorService/ConfiguratorService';\nimport { JwtSimpleGuard } from './jwt/jwt.strategy';\nimport { AuthenticateGenService } from './middleware/authenticateGen';\nimport { AccessiDatabaseUpdater } from './database-updates/AccessiDatabaseUpdater';\n\nexport interface JwtOptions {\n secret: string;\n expiresIn: string;\n}\n\nexport interface EmailOptions {\n host: string;\n port: number;\n secure: boolean;\n requireTLS : boolean;\n tls: {\n rejectUnauthorized: boolean,\n }\n from: string;\n auth: {\n user: string;\n pass: string;\n };\n}\n\nexport interface ExtensionFieldsOptions {\n databaseOptions: Options;\n objectKey: string;\n tableName: string;\n tableFields: string[];\n tableJoinFieldName: string;\n}\n\nexport interface PublicAuthRateLimitRuleOptions {\n windowMs: number;\n maxAttempts: number;\n}\n\nexport interface PublicAuthRateLimitOptions {\n enabled?: boolean;\n login?: PublicAuthRateLimitRuleOptions;\n register?: PublicAuthRateLimitRuleOptions;\n passwordResetEmail?: PublicAuthRateLimitRuleOptions;\n passwordResetConfirm?: PublicAuthRateLimitRuleOptions;\n getUserByToken?: PublicAuthRateLimitRuleOptions;\n}\n\nexport interface AccessiOptions {\n databaseOptions: Options;\n /**\n * Basepath del sito es: 'http://www.il-mio-sito.it/nome-progetto(se c'è)'\n */\n confirmationEmailUrl: string;\n /**\n * Percorso della pagina di reset personalizzata es. http://localhost:4200/#/admin/reset-password\n * N.B si sostituisce al confirmationMailURl\n */\n customResetPage?: string;\n confirmationEmailReturnUrl: string;\n confirmationEmailPrefix?: string;\n encryptionKey: string;\n mockDemoUser: boolean;\n passwordExpiration?: boolean;\n passwordExpirationDays?: number;\n legacyPasswordMigrationOnStartup?: boolean;\n autoUpdateDatabase?: boolean;\n jwtOptions: JwtOptions;\n emailOptions: EmailOptions;\n publicAuthRateLimit?: PublicAuthRateLimitOptions;\n extensionFieldsOptions?: ExtensionFieldsOptions[];\n}\n\n@Global()\n@Module({\n controllers: [\n EmailController,\n AuthController,\n PermissionController,\n UserController,\n FiltriController,\n ConfiguratorController\n ],\n providers: [AuthService, UserService, EmailService, PermissionService, FiltriService, ConfiguratorService, JwtSimpleGuard, AuthenticateGenService, AccessiDatabaseUpdater],\n exports: [AuthService, UserService, EmailService, PermissionService, FiltriService, ConfiguratorService, JwtSimpleGuard, AuthenticateGenService],\n})\nexport class AccessiModule {\n static forRoot(options: AccessiOptions): DynamicModule {\n return {\n module: AccessiModule,\n providers: [\n {\n provide: 'ACCESSI_OPTIONS',\n useValue: options,\n },\n AuthService,\n UserService,\n EmailService,\n PermissionService,\n FiltriService,\n ConfiguratorService,\n JwtSimpleGuard,\n AuthenticateGenService,\n AccessiDatabaseUpdater\n ],\n exports: [\n 'ACCESSI_OPTIONS',\n AuthService,\n UserService,\n EmailService,\n PermissionService,\n FiltriService,\n ConfiguratorService,\n JwtSimpleGuard,\n AuthenticateGenService\n ],\n };\n }\n}\n"]}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { Request, Response } from 'express';
|
|
2
|
+
import { Logger } from '../../Logger';
|
|
2
3
|
import { AccessiOptions } from '../AccessiModule';
|
|
4
|
+
import { ConfirmResetPasswordRequest, GetUserByTokenRequest, LoginRequest } from '../Dtos';
|
|
3
5
|
import { AuthService } from '../Services/AuthService/AuthService';
|
|
4
|
-
import { LoginRequest } from '../Dtos';
|
|
5
|
-
import { Logger } from '../../Logger';
|
|
6
6
|
export declare class AuthController {
|
|
7
7
|
private readonly authService;
|
|
8
8
|
private readonly options;
|
|
9
9
|
logger: Logger;
|
|
10
10
|
constructor(authService: AuthService, options: AccessiOptions);
|
|
11
|
-
resetPassword(request: Request, res: Response, token: string,
|
|
12
|
-
getUserByToken(request: Request,
|
|
11
|
+
resetPassword(request: Request, res: Response, token: string, body: ConfirmResetPasswordRequest): Promise<Response<any, Record<string, any>>>;
|
|
12
|
+
getUserByToken(request: Request, body: GetUserByTokenRequest, res: Response): Promise<Response<any, Record<string, any>>>;
|
|
13
13
|
login(request: Request, loginRequest: LoginRequest, res: Response): Promise<Response<any, Record<string, any>>>;
|
|
14
14
|
}
|
|
@@ -59,10 +59,10 @@ exports.AuthController = void 0;
|
|
|
59
59
|
const common_1 = require("@nestjs/common");
|
|
60
60
|
const swagger_1 = require("@nestjs/swagger");
|
|
61
61
|
const jwt = __importStar(require("jsonwebtoken"));
|
|
62
|
+
const Logger_1 = require("../../Logger");
|
|
62
63
|
const Utilities_1 = require("../../Utilities");
|
|
63
|
-
const AuthService_1 = require("../Services/AuthService/AuthService");
|
|
64
64
|
const Dtos_1 = require("../Dtos");
|
|
65
|
-
const
|
|
65
|
+
const AuthService_1 = require("../Services/AuthService/AuthService");
|
|
66
66
|
const publicAuthRateLimit_1 = require("../security/publicAuthRateLimit");
|
|
67
67
|
let AuthController = AuthController_1 = class AuthController {
|
|
68
68
|
constructor(authService, options) {
|
|
@@ -70,14 +70,14 @@ let AuthController = AuthController_1 = class AuthController {
|
|
|
70
70
|
this.options = options;
|
|
71
71
|
this.logger = new Logger_1.Logger(AuthController_1.name);
|
|
72
72
|
}
|
|
73
|
-
resetPassword(request, res, token,
|
|
73
|
+
resetPassword(request, res, token, body) {
|
|
74
74
|
return __awaiter(this, void 0, void 0, function* () {
|
|
75
75
|
try {
|
|
76
76
|
const rateLimitDecision = (0, publicAuthRateLimit_1.checkPublicAuthRateLimit)(this.options, 'passwordResetConfirm', request);
|
|
77
77
|
if (!rateLimitDecision.allowed) {
|
|
78
78
|
return (0, publicAuthRateLimit_1.sendPublicAuthRateLimitExceeded)(res, rateLimitDecision.retryAfterSeconds);
|
|
79
79
|
}
|
|
80
|
-
yield this.authService.confirmResetPassword(token, newPassword);
|
|
80
|
+
yield this.authService.confirmResetPassword(token, body.newPassword);
|
|
81
81
|
return Utilities_1.RestUtilities.sendOKMessage(res, 'Password aggiornata con successo!');
|
|
82
82
|
}
|
|
83
83
|
catch (error) {
|
|
@@ -85,17 +85,17 @@ let AuthController = AuthController_1 = class AuthController {
|
|
|
85
85
|
}
|
|
86
86
|
});
|
|
87
87
|
}
|
|
88
|
-
getUserByToken(request,
|
|
88
|
+
getUserByToken(request, body, res) {
|
|
89
89
|
return __awaiter(this, void 0, void 0, function* () {
|
|
90
90
|
try {
|
|
91
91
|
const rateLimitDecision = (0, publicAuthRateLimit_1.checkPublicAuthRateLimit)(this.options, 'getUserByToken', request);
|
|
92
92
|
if (!rateLimitDecision.allowed) {
|
|
93
93
|
return (0, publicAuthRateLimit_1.sendPublicAuthRateLimitExceeded)(res, rateLimitDecision.retryAfterSeconds);
|
|
94
94
|
}
|
|
95
|
-
if (!token) {
|
|
95
|
+
if (!(body === null || body === void 0 ? void 0 : body.token)) {
|
|
96
96
|
return Utilities_1.RestUtilities.sendErrorMessage(res, 'Token non fornito', AuthController_1.name, common_1.HttpStatus.BAD_REQUEST);
|
|
97
97
|
}
|
|
98
|
-
const authenticatedPayload = yield this.authService.getAuthenticatedTokenPayload(token);
|
|
98
|
+
const authenticatedPayload = yield this.authService.getAuthenticatedTokenPayload(body.token);
|
|
99
99
|
return Utilities_1.RestUtilities.sendBaseResponse(res, { userData: authenticatedPayload });
|
|
100
100
|
}
|
|
101
101
|
catch (error) {
|
|
@@ -114,7 +114,6 @@ let AuthController = AuthController_1 = class AuthController {
|
|
|
114
114
|
if (!userData) {
|
|
115
115
|
return Utilities_1.RestUtilities.sendInvalidCredentials(res);
|
|
116
116
|
}
|
|
117
|
-
// Generazione del token JWT
|
|
118
117
|
const tokenData = {
|
|
119
118
|
utente: userData === null || userData === void 0 ? void 0 : userData.utente,
|
|
120
119
|
};
|
|
@@ -128,7 +127,7 @@ let AuthController = AuthController_1 = class AuthController {
|
|
|
128
127
|
return Utilities_1.RestUtilities.sendBaseResponse(res, userData);
|
|
129
128
|
}
|
|
130
129
|
catch (error) {
|
|
131
|
-
if (error.message === 'PASSWORD_EXPIRED') {
|
|
130
|
+
if ((error === null || error === void 0 ? void 0 : error.message) === 'PASSWORD_EXPIRED') {
|
|
132
131
|
this.logger.warning('Password scaduta, cambiare password ', error);
|
|
133
132
|
return Utilities_1.RestUtilities.sendPasswordExpired(res);
|
|
134
133
|
}
|
|
@@ -140,37 +139,56 @@ let AuthController = AuthController_1 = class AuthController {
|
|
|
140
139
|
};
|
|
141
140
|
exports.AuthController = AuthController;
|
|
142
141
|
__decorate([
|
|
143
|
-
(0, swagger_1.ApiOperation)({ summary: 'Conferma il reset della password', operationId:
|
|
142
|
+
(0, swagger_1.ApiOperation)({ summary: 'Conferma il reset della password', operationId: 'resetPassword' }),
|
|
144
143
|
(0, swagger_1.ApiParam)({ name: 'token', description: 'Token per il reset della password', required: true }),
|
|
145
|
-
(0, swagger_1.ApiBody)({
|
|
146
|
-
(0, swagger_1.ApiResponse)({
|
|
147
|
-
|
|
144
|
+
(0, swagger_1.ApiBody)({ type: Dtos_1.ConfirmResetPasswordRequest }),
|
|
145
|
+
(0, swagger_1.ApiResponse)({
|
|
146
|
+
status: 200,
|
|
147
|
+
description: 'Password aggiornata con successo',
|
|
148
|
+
type: Dtos_1.ActionResponse,
|
|
149
|
+
}),
|
|
150
|
+
(0, swagger_1.ApiResponse)({
|
|
151
|
+
status: 400,
|
|
152
|
+
description: 'Errore nella richiesta o token non valido',
|
|
153
|
+
type: Dtos_1.ErrorResponse,
|
|
154
|
+
}),
|
|
148
155
|
(0, common_1.Post)('confirm-reset-password/:token'),
|
|
149
156
|
__param(0, (0, common_1.Req)()),
|
|
150
157
|
__param(1, (0, common_1.Res)()),
|
|
151
158
|
__param(2, (0, common_1.Param)('token')),
|
|
152
|
-
__param(3, (0, common_1.Body)(
|
|
159
|
+
__param(3, (0, common_1.Body)()),
|
|
153
160
|
__metadata("design:type", Function),
|
|
154
|
-
__metadata("design:paramtypes", [Object, Object, String,
|
|
161
|
+
__metadata("design:paramtypes", [Object, Object, String, Dtos_1.ConfirmResetPasswordRequest]),
|
|
155
162
|
__metadata("design:returntype", Promise)
|
|
156
163
|
], AuthController.prototype, "resetPassword", null);
|
|
157
164
|
__decorate([
|
|
158
|
-
(0, swagger_1.ApiOperation)({
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
165
|
+
(0, swagger_1.ApiOperation)({
|
|
166
|
+
summary: 'Recupera le informazioni utente dal token JWT',
|
|
167
|
+
operationId: 'getUserByToken',
|
|
168
|
+
}),
|
|
169
|
+
(0, swagger_1.ApiBody)({ type: Dtos_1.GetUserByTokenRequest }),
|
|
170
|
+
(0, swagger_1.ApiResponse)({
|
|
171
|
+
status: 200,
|
|
172
|
+
description: 'Informazioni utente recuperate con successo',
|
|
173
|
+
type: Dtos_1.GetUserByTokenResponse,
|
|
174
|
+
}),
|
|
175
|
+
(0, swagger_1.ApiResponse)({
|
|
176
|
+
status: 401,
|
|
177
|
+
description: 'Token non valido o scaduto',
|
|
178
|
+
type: Dtos_1.ErrorResponse,
|
|
179
|
+
}),
|
|
162
180
|
(0, common_1.Post)('get-user-by-token'),
|
|
163
181
|
__param(0, (0, common_1.Req)()),
|
|
164
|
-
__param(1, (0, common_1.Body)(
|
|
182
|
+
__param(1, (0, common_1.Body)()),
|
|
165
183
|
__param(2, (0, common_1.Res)()),
|
|
166
184
|
__metadata("design:type", Function),
|
|
167
|
-
__metadata("design:paramtypes", [Object,
|
|
185
|
+
__metadata("design:paramtypes", [Object, Dtos_1.GetUserByTokenRequest, Object]),
|
|
168
186
|
__metadata("design:returntype", Promise)
|
|
169
187
|
], AuthController.prototype, "getUserByToken", null);
|
|
170
188
|
__decorate([
|
|
171
189
|
(0, swagger_1.ApiOperation)({
|
|
172
190
|
summary: 'Effettua il login utente',
|
|
173
|
-
description:
|
|
191
|
+
description: "Autentica l'utente con email e password. Restituisce un token JWT e i dati dell'utente se le credenziali sono corrette.",
|
|
174
192
|
operationId: 'login',
|
|
175
193
|
}),
|
|
176
194
|
(0, swagger_1.ApiBody)({ type: Dtos_1.LoginRequest }),
|
|
@@ -182,20 +200,12 @@ __decorate([
|
|
|
182
200
|
(0, swagger_1.ApiResponse)({
|
|
183
201
|
status: 401,
|
|
184
202
|
description: 'Credenziali non valide',
|
|
203
|
+
type: Dtos_1.ErrorResponse,
|
|
185
204
|
}),
|
|
186
205
|
(0, swagger_1.ApiResponse)({
|
|
187
206
|
status: 403,
|
|
188
|
-
description:
|
|
189
|
-
|
|
190
|
-
example: {
|
|
191
|
-
message: {
|
|
192
|
-
severity: 'warning',
|
|
193
|
-
statusCode: 2, // o il valore di StatusCode.Warning
|
|
194
|
-
code: 'PASSWORD_EXPIRED',
|
|
195
|
-
message: 'Password scaduta. È necessario aggiornarla.',
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
}
|
|
207
|
+
description: 'Password scaduta, e necessario aggiornarla.',
|
|
208
|
+
type: Dtos_1.PasswordExpiredResponse,
|
|
199
209
|
}),
|
|
200
210
|
(0, common_1.Post)('login'),
|
|
201
211
|
__param(0, (0, common_1.Req)()),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AuthController.js","sourceRoot":"","sources":["../../../src/accessi-module/Controllers/AuthController.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA6F;AAC7F,6CAAwF;AAExF,kDAAoC;AACpC,+CAAgD;AAEhD,qEAAkE;AAClE,kCAAsD;AACtD,yCAAsC;AACtC,yEAGyC;AAIlC,IAAM,cAAc,sBAApB,MAAM,cAAc;IAGzB,YACmB,WAAwB,EACd,OAAwC;QADlD,gBAAW,GAAX,WAAW,CAAa;QACG,YAAO,GAAP,OAAO,CAAgB;QAHrE,WAAM,GAAW,IAAI,eAAM,CAAC,gBAAc,CAAC,IAAI,CAAC,CAAC;IAI7C,CAAC;IAQC,aAAa,CACV,OAAgB,EAChB,GAAa,EACJ,KAAa,EACR,WAAmB;;YAExC,IAAI,CAAC;gBACH,MAAM,iBAAiB,GAAG,IAAA,8CAAwB,EAChD,IAAI,CAA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F;KACF,CAAC;IACD,IAAA,aAAI,EAAC,OAAO,CAAC;IACD,WAAA,IAAA,YAAG,GAAE,CAAA;IAAoB,WAAA,IAAA,aAAI,GAAE,CAAA;IAA8B,WAAA,IAAA,YAAG,GAAE,CAAA;;6CAApB,mBAAY;;2CA0CtE;yBAjJU,cAAc;IAF1B,IAAA,iBAAO,EAAC,MAAM,CAAC;IACf,IAAA,mBAAU,EAAC,cAAc,CAAC;IAMtB,WAAA,IAAA,eAAM,EAAC,iBAAiB,CAAC,CAAA;qCADI,yBAAW;GAJhC,cAAc,CAkJ1B","sourcesContent":["import { Body, Controller, HttpStatus, Inject, Param, Post, Req, Res } from '@nestjs/common';\r\nimport { ApiOperation, ApiTags, ApiResponse, ApiParam, ApiBody } from '@nestjs/swagger';\r\nimport { Request, Response } from 'express';\r\nimport * as jwt from 'jsonwebtoken';\r\nimport { RestUtilities } from '../../Utilities';\r\nimport { AccessiOptions } from '../AccessiModule';\r\nimport { AuthService } from '../Services/AuthService/AuthService';\r\nimport { LoginRequest, LoginResponse } from '../Dtos';\r\nimport { Logger } from '../../Logger';\r\nimport {\r\n checkPublicAuthRateLimit,\r\n sendPublicAuthRateLimitExceeded,\r\n} from '../security/publicAuthRateLimit';\r\n\r\n@ApiTags('Auth')\r\n@Controller('accessi/auth')\r\nexport class AuthController {\r\n\r\n logger: Logger = new Logger(AuthController.name);\r\n constructor(\r\n private readonly authService: AuthService,\r\n @Inject('ACCESSI_OPTIONS') private readonly options: AccessiOptions\r\n ) { }\r\n\r\n @ApiOperation({ summary: 'Conferma il reset della password', operationId: \"resetPassword\" })\r\n @ApiParam({ name: 'token', description: 'Token per il reset della password', required: true })\r\n @ApiBody({ schema: { properties: { newPassword: { type: 'string', description: 'Nuova password da impostare' } } } })\r\n @ApiResponse({ status: 200, description: 'Password aggiornata con successo' })\r\n @ApiResponse({ status: 400, description: 'Errore nella richiesta o token non valido' })\r\n @Post('confirm-reset-password/:token')\r\n async resetPassword(\r\n @Req() request: Request,\r\n @Res() res: Response,\r\n @Param('token') token: string,\r\n @Body(\"newPassword\") newPassword: string,\r\n ) {\r\n try {\r\n const rateLimitDecision = checkPublicAuthRateLimit(\r\n this.options,\r\n 'passwordResetConfirm',\r\n request,\r\n );\r\n if (!rateLimitDecision.allowed) {\r\n return sendPublicAuthRateLimitExceeded(res, rateLimitDecision.retryAfterSeconds);\r\n }\r\n\r\n await this.authService.confirmResetPassword(token, newPassword);\r\n return RestUtilities.sendOKMessage(res, 'Password aggiornata con successo!');\r\n } catch (error) {\r\n return RestUtilities.sendErrorMessage(res, error, AuthController.name, HttpStatus.BAD_REQUEST);\r\n }\r\n }\r\n\r\n @ApiOperation({ summary: 'Recupera le informazioni utente dal token JWT', operationId: \"getUserByToken\" })\r\n @ApiBody({ schema: { properties: { token: { type: 'string', description: 'JWT dell\\'utente' } } } })\r\n @ApiResponse({ status: 200, description: 'Informazioni utente recuperate con successo' })\r\n @ApiResponse({ status: 401, description: 'Token non valido o scaduto' })\r\n @Post('get-user-by-token')\r\n async getUserByToken(\r\n @Req() request: Request,\r\n @Body('token') token: string,\r\n @Res() res: Response,\r\n ) {\r\n try {\r\n const rateLimitDecision = checkPublicAuthRateLimit(\r\n this.options,\r\n 'getUserByToken',\r\n request,\r\n );\r\n if (!rateLimitDecision.allowed) {\r\n return sendPublicAuthRateLimitExceeded(res, rateLimitDecision.retryAfterSeconds);\r\n }\r\n\r\n if (!token) {\r\n return RestUtilities.sendErrorMessage(\r\n res,\r\n 'Token non fornito',\r\n AuthController.name,\r\n HttpStatus.BAD_REQUEST,\r\n );\r\n }\r\n\r\n const authenticatedPayload = await this.authService.getAuthenticatedTokenPayload(token);\r\n return RestUtilities.sendBaseResponse(res, { userData: authenticatedPayload });\r\n } catch (error) {\r\n return RestUtilities.sendErrorMessage(res, error, AuthController.name, HttpStatus.UNAUTHORIZED);\r\n }\r\n }\r\n\r\n @ApiOperation({\r\n summary: 'Effettua il login utente',\r\n description: 'Autentica l\\'utente con email e password. Restituisce un token JWT e i dati dell\\'utente se le credenziali sono corrette.',\r\n operationId: 'login',\r\n })\r\n @ApiBody({ type: LoginRequest })\r\n @ApiResponse({\r\n status: 200,\r\n description: 'Login effettuato con successo',\r\n type: LoginResponse,\r\n })\r\n @ApiResponse({\r\n status: 401,\r\n description: 'Credenziali non valide',\r\n })\r\n @ApiResponse({\r\n status: 403,\r\n description: \"Password scaduta, è necessatio aggiornarla. \",\r\n schema: {\r\n example: {\r\n message: {\r\n severity: 'warning',\r\n statusCode: 2, // o il valore di StatusCode.Warning\r\n code: 'PASSWORD_EXPIRED',\r\n message: 'Password scaduta. È necessario aggiornarla.',\r\n }\r\n }\r\n }\r\n })\r\n @Post('login')\r\n async login(@Req() request: Request, @Body() loginRequest: LoginRequest, @Res() res: Response) {\r\n try {\r\n const rateLimitDecision = checkPublicAuthRateLimit(\r\n this.options,\r\n 'login',\r\n request,\r\n [loginRequest?.email],\r\n );\r\n if (!rateLimitDecision.allowed) {\r\n return sendPublicAuthRateLimitExceeded(res, rateLimitDecision.retryAfterSeconds);\r\n }\r\n\r\n const userData = await this.authService.login(loginRequest);\r\n if (!userData) {\r\n return RestUtilities.sendInvalidCredentials(res);\r\n }\r\n\r\n // Generazione del token JWT\r\n const tokenData = {\r\n utente: userData?.utente,\r\n }\r\n\r\n userData.token = {\r\n expiresIn: this.options.jwtOptions.expiresIn,\r\n value: jwt.sign(tokenData, this.options.jwtOptions.secret, {\r\n expiresIn: this.options.jwtOptions.expiresIn as any,\r\n }),\r\n type: 'Bearer',\r\n };\r\n\r\n return RestUtilities.sendBaseResponse(res, userData);\r\n } catch (error) {\r\n\r\n if (error.message === 'PASSWORD_EXPIRED') {\r\n this.logger.warning('Password scaduta, cambiare password ', error)\r\n return RestUtilities.sendPasswordExpired(res)\r\n }\r\n\r\n this.logger.error('Errore durante il login', error);\r\n return RestUtilities.sendInvalidCredentials(res);\r\n }\r\n \r\n }\r\n}\r\n\r\n"]}
|
|
1
|
+
{"version":3,"file":"AuthController.js","s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O,EAAE,0BAA0B;QACnC,WAAW,EACT,yHAAyH;QAC3H,WAAW,EAAE,OAAO;KACrB,CAAC;IACD,IAAA,iBAAO,EAAC,EAAE,IAAI,EAAE,mBAAY,EAAE,CAAC;IAC/B,IAAA,qBAAW,EAAC;QACX,MAAM,EAAE,GAAG;QACX,WAAW,EAAE,+BAA+B;QAC5C,IAAI,EAAE,oBAAa;KACpB,CAAC;IACD,IAAA,qBAAW,EAAC;QACX,MAAM,EAAE,GAAG;QACX,WAAW,EAAE,wBAAwB;QACrC,IAAI,EAAE,oBAAa;KACpB,CAAC;IACD,IAAA,qBAAW,EAAC;QACX,MAAM,EAAE,GAAG;QACX,WAAW,EAAE,6CAA6C;QAC1D,IAAI,EAAE,8BAAuB;KAC9B,CAAC;IACD,IAAA,aAAI,EAAC,OAAO,CAAC;IACD,WAAA,IAAA,YAAG,GAAE,CAAA;IAAoB,WAAA,IAAA,aAAI,GAAE,CAAA;IAA8B,WAAA,IAAA,YAAG,GAAE,CAAA;;6CAApB,mBAAY;;2CAuCtE;yBA1JU,cAAc;IAF1B,IAAA,iBAAO,EAAC,MAAM,CAAC;IACf,IAAA,mBAAU,EAAC,cAAc,CAAC;IAMtB,WAAA,IAAA,eAAM,EAAC,iBAAiB,CAAC,CAAA;qCADI,yBAAW;GAJhC,cAAc,CA2J1B","sourcesContent":["import { Body, Controller, HttpStatus, Inject, Param, Post, Req, Res } from '@nestjs/common';\nimport { ApiBody, ApiOperation, ApiParam, ApiResponse, ApiTags } from '@nestjs/swagger';\nimport { Request, Response } from 'express';\nimport * as jwt from 'jsonwebtoken';\nimport { Logger } from '../../Logger';\nimport { RestUtilities } from '../../Utilities';\nimport { AccessiOptions } from '../AccessiModule';\nimport {\n ActionResponse,\n ConfirmResetPasswordRequest,\n ErrorResponse,\n GetUserByTokenRequest,\n GetUserByTokenResponse,\n LoginRequest,\n LoginResponse,\n PasswordExpiredResponse,\n} from '../Dtos';\nimport { AuthService } from '../Services/AuthService/AuthService';\nimport {\n checkPublicAuthRateLimit,\n sendPublicAuthRateLimitExceeded,\n} from '../security/publicAuthRateLimit';\n\n@ApiTags('Auth')\n@Controller('accessi/auth')\nexport class AuthController {\n logger: Logger = new Logger(AuthController.name);\n\n constructor(\n private readonly authService: AuthService,\n @Inject('ACCESSI_OPTIONS') private readonly options: AccessiOptions,\n ) {}\n\n @ApiOperation({ summary: 'Conferma il reset della password', operationId: 'resetPassword' })\n @ApiParam({ name: 'token', description: 'Token per il reset della password', required: true })\n @ApiBody({ type: ConfirmResetPasswordRequest })\n @ApiResponse({\n status: 200,\n description: 'Password aggiornata con successo',\n type: ActionResponse,\n })\n @ApiResponse({\n status: 400,\n description: 'Errore nella richiesta o token non valido',\n type: ErrorResponse,\n })\n @Post('confirm-reset-password/:token')\n async resetPassword(\n @Req() request: Request,\n @Res() res: Response,\n @Param('token') token: string,\n @Body() body: ConfirmResetPasswordRequest,\n ) {\n try {\n const rateLimitDecision = checkPublicAuthRateLimit(\n this.options,\n 'passwordResetConfirm',\n request,\n );\n if (!rateLimitDecision.allowed) {\n return sendPublicAuthRateLimitExceeded(res, rateLimitDecision.retryAfterSeconds);\n }\n\n await this.authService.confirmResetPassword(token, body.newPassword);\n return RestUtilities.sendOKMessage(res, 'Password aggiornata con successo!');\n } catch (error) {\n return RestUtilities.sendErrorMessage(res, error, AuthController.name, HttpStatus.BAD_REQUEST);\n }\n }\n\n @ApiOperation({\n summary: 'Recupera le informazioni utente dal token JWT',\n operationId: 'getUserByToken',\n })\n @ApiBody({ type: GetUserByTokenRequest })\n @ApiResponse({\n status: 200,\n description: 'Informazioni utente recuperate con successo',\n type: GetUserByTokenResponse,\n })\n @ApiResponse({\n status: 401,\n description: 'Token non valido o scaduto',\n type: ErrorResponse,\n })\n @Post('get-user-by-token')\n async getUserByToken(\n @Req() request: Request,\n @Body() body: GetUserByTokenRequest,\n @Res() res: Response,\n ) {\n try {\n const rateLimitDecision = checkPublicAuthRateLimit(\n this.options,\n 'getUserByToken',\n request,\n );\n if (!rateLimitDecision.allowed) {\n return sendPublicAuthRateLimitExceeded(res, rateLimitDecision.retryAfterSeconds);\n }\n\n if (!body?.token) {\n return RestUtilities.sendErrorMessage(\n res,\n 'Token non fornito',\n AuthController.name,\n HttpStatus.BAD_REQUEST,\n );\n }\n\n const authenticatedPayload = await this.authService.getAuthenticatedTokenPayload(body.token);\n return RestUtilities.sendBaseResponse(res, { userData: authenticatedPayload });\n } catch (error) {\n return RestUtilities.sendErrorMessage(res, error, AuthController.name, HttpStatus.UNAUTHORIZED);\n }\n }\n\n @ApiOperation({\n summary: 'Effettua il login utente',\n description:\n \"Autentica l'utente con email e password. Restituisce un token JWT e i dati dell'utente se le credenziali sono corrette.\",\n operationId: 'login',\n })\n @ApiBody({ type: LoginRequest })\n @ApiResponse({\n status: 200,\n description: 'Login effettuato con successo',\n type: LoginResponse,\n })\n @ApiResponse({\n status: 401,\n description: 'Credenziali non valide',\n type: ErrorResponse,\n })\n @ApiResponse({\n status: 403,\n description: 'Password scaduta, e necessario aggiornarla.',\n type: PasswordExpiredResponse,\n })\n @Post('login')\n async login(@Req() request: Request, @Body() loginRequest: LoginRequest, @Res() res: Response) {\n try {\n const rateLimitDecision = checkPublicAuthRateLimit(\n this.options,\n 'login',\n request,\n [loginRequest?.email],\n );\n if (!rateLimitDecision.allowed) {\n return sendPublicAuthRateLimitExceeded(res, rateLimitDecision.retryAfterSeconds);\n }\n\n const userData = await this.authService.login(loginRequest);\n if (!userData) {\n return RestUtilities.sendInvalidCredentials(res);\n }\n\n const tokenData = {\n utente: userData?.utente,\n };\n\n userData.token = {\n expiresIn: this.options.jwtOptions.expiresIn,\n value: jwt.sign(tokenData, this.options.jwtOptions.secret, {\n expiresIn: this.options.jwtOptions.expiresIn as any,\n }),\n type: 'Bearer',\n };\n\n return RestUtilities.sendBaseResponse(res, userData);\n } catch (error) {\n if ((error as Error)?.message === 'PASSWORD_EXPIRED') {\n this.logger.warning('Password scaduta, cambiare password ', error);\n return RestUtilities.sendPasswordExpired(res);\n }\n\n this.logger.error('Errore durante il login', error);\n return RestUtilities.sendInvalidCredentials(res);\n }\n }\n}\n"]}
|
|
@@ -30,6 +30,7 @@ const Dtos_1 = require("../Dtos");
|
|
|
30
30
|
const ConfiguratorService_1 = require("../Services/ConfiguratorService/ConfiguratorService");
|
|
31
31
|
const UserService_1 = require("../Services/UserService/UserService");
|
|
32
32
|
const jwt_strategy_1 = require("../jwt/jwt.strategy");
|
|
33
|
+
const accessControl_1 = require("../security/accessControl");
|
|
33
34
|
let ConfiguratorController = ConfiguratorController_1 = class ConfiguratorController {
|
|
34
35
|
constructor(options, userService, configuratorService) {
|
|
35
36
|
this.options = options;
|
|
@@ -38,25 +39,21 @@ let ConfiguratorController = ConfiguratorController_1 = class ConfiguratorContro
|
|
|
38
39
|
}
|
|
39
40
|
setMenuEnabled(codiceMenu, body, req, res) {
|
|
40
41
|
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
-
var _a, _b;
|
|
42
42
|
try {
|
|
43
43
|
if (!codiceMenu)
|
|
44
|
-
throw new Error('Il codice del menu
|
|
44
|
+
throw new Error('Il codice del menu e obbligatorio.');
|
|
45
45
|
if ((body === null || body === void 0 ? void 0 : body.enabled) === undefined)
|
|
46
|
-
throw new Error('Lo stato di abilitazione
|
|
47
|
-
const
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
const canConfigure = ((_b = user === null || user === void 0 ? void 0 : user.utente) === null || _b === void 0 ? void 0 : _b.flagAdminConfigurator) ||
|
|
53
|
-
(yield this.userService.isAdminConfigurator(codiceUtente));
|
|
46
|
+
throw new Error('Lo stato di abilitazione e obbligatorio.');
|
|
47
|
+
const authenticatedUser = (0, accessControl_1.getAuthenticatedAccessiUser)(req);
|
|
48
|
+
const canConfigure = authenticatedUser.flagSuper ||
|
|
49
|
+
authenticatedUser.flagAdminConfigurator ||
|
|
50
|
+
(yield this.userService.isAdminConfigurator(authenticatedUser.codiceUtente));
|
|
54
51
|
if (!canConfigure) {
|
|
55
52
|
return Utilities_1.RestUtilities.sendErrorMessage(res, 'Utente non autorizzato ad aggiornare i menu.', ConfiguratorController_1.name, 403);
|
|
56
53
|
}
|
|
57
54
|
yield this.configuratorService.setMenuEnabled(codiceMenu, body.enabled);
|
|
58
55
|
const action = body.enabled ? 'abilitato' : 'disabilitato';
|
|
59
|
-
return Utilities_1.RestUtilities.sendOKMessage(res, `Il menu ${codiceMenu}
|
|
56
|
+
return Utilities_1.RestUtilities.sendOKMessage(res, `Il menu ${codiceMenu} e stato ${action} con successo.`);
|
|
60
57
|
}
|
|
61
58
|
catch (error) {
|
|
62
59
|
return Utilities_1.RestUtilities.sendErrorMessage(res, error, ConfiguratorController_1.name);
|
|
@@ -65,25 +62,21 @@ let ConfiguratorController = ConfiguratorController_1 = class ConfiguratorContro
|
|
|
65
62
|
}
|
|
66
63
|
setGroupEnabled(codiceGruppo, body, req, res) {
|
|
67
64
|
return __awaiter(this, void 0, void 0, function* () {
|
|
68
|
-
var _a, _b;
|
|
69
65
|
try {
|
|
70
66
|
if (!codiceGruppo)
|
|
71
|
-
throw new Error('Il codice del gruppo
|
|
67
|
+
throw new Error('Il codice del gruppo e obbligatorio.');
|
|
72
68
|
if ((body === null || body === void 0 ? void 0 : body.enabled) === undefined)
|
|
73
|
-
throw new Error('Lo stato di abilitazione
|
|
74
|
-
const
|
|
75
|
-
const
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
-
const canConfigure = ((_b = user === null || user === void 0 ? void 0 : user.utente) === null || _b === void 0 ? void 0 : _b.flagAdminConfigurator) ||
|
|
80
|
-
(yield this.userService.isAdminConfigurator(codiceUtente));
|
|
69
|
+
throw new Error('Lo stato di abilitazione e obbligatorio.');
|
|
70
|
+
const authenticatedUser = (0, accessControl_1.getAuthenticatedAccessiUser)(req);
|
|
71
|
+
const canConfigure = authenticatedUser.flagSuper ||
|
|
72
|
+
authenticatedUser.flagAdminConfigurator ||
|
|
73
|
+
(yield this.userService.isAdminConfigurator(authenticatedUser.codiceUtente));
|
|
81
74
|
if (!canConfigure) {
|
|
82
75
|
return Utilities_1.RestUtilities.sendErrorMessage(res, 'Utente non autorizzato ad aggiornare i gruppi menu.', ConfiguratorController_1.name, 403);
|
|
83
76
|
}
|
|
84
77
|
yield this.configuratorService.setGroupEnabled(codiceGruppo, body.enabled);
|
|
85
78
|
const action = body.enabled ? 'abilitato' : 'disabilitato';
|
|
86
|
-
return Utilities_1.RestUtilities.sendOKMessage(res, `Il gruppo ${codiceGruppo}
|
|
79
|
+
return Utilities_1.RestUtilities.sendOKMessage(res, `Il gruppo ${codiceGruppo} e stato ${action} con successo.`);
|
|
87
80
|
}
|
|
88
81
|
catch (error) {
|
|
89
82
|
return Utilities_1.RestUtilities.sendErrorMessage(res, error, ConfiguratorController_1.name);
|
|
@@ -104,10 +97,11 @@ __decorate([
|
|
|
104
97
|
example: 'MNU001',
|
|
105
98
|
}),
|
|
106
99
|
(0, swagger_1.ApiBody)({ type: Dtos_1.UpdateEnabledStatusRequest }),
|
|
107
|
-
(0, swagger_1.ApiResponse)({ status: 200, description: 'Stato del menu aggiornato con successo' }),
|
|
108
|
-
(0, swagger_1.ApiResponse)({ status: 400, description: 'Errore di validazione nei dati inviati' }),
|
|
109
|
-
(0, swagger_1.ApiResponse)({ status:
|
|
110
|
-
(0, swagger_1.ApiResponse)({ status:
|
|
100
|
+
(0, swagger_1.ApiResponse)({ status: 200, description: 'Stato del menu aggiornato con successo', type: Dtos_1.ActionResponse }),
|
|
101
|
+
(0, swagger_1.ApiResponse)({ status: 400, description: 'Errore di validazione nei dati inviati', type: Dtos_1.ErrorResponse }),
|
|
102
|
+
(0, swagger_1.ApiResponse)({ status: 401, description: 'Utente non autenticato o token non valido', type: Dtos_1.ErrorResponse }),
|
|
103
|
+
(0, swagger_1.ApiResponse)({ status: 403, description: "Utente non autorizzato ad eseguire l'operazione", type: Dtos_1.ErrorResponse }),
|
|
104
|
+
(0, swagger_1.ApiResponse)({ status: 500, description: 'Errore interno del server', type: Dtos_1.ErrorResponse }),
|
|
111
105
|
(0, common_1.Patch)('menus/:codiceMenu/enabled'),
|
|
112
106
|
__param(0, (0, common_1.Param)('codiceMenu')),
|
|
113
107
|
__param(1, (0, common_1.Body)()),
|
|
@@ -129,10 +123,11 @@ __decorate([
|
|
|
129
123
|
example: 'GRP01',
|
|
130
124
|
}),
|
|
131
125
|
(0, swagger_1.ApiBody)({ type: Dtos_1.UpdateEnabledStatusRequest }),
|
|
132
|
-
(0, swagger_1.ApiResponse)({ status: 200, description: 'Stato del gruppo aggiornato con successo' }),
|
|
133
|
-
(0, swagger_1.ApiResponse)({ status: 400, description: 'Errore di validazione nei dati inviati' }),
|
|
134
|
-
(0, swagger_1.ApiResponse)({ status:
|
|
135
|
-
(0, swagger_1.ApiResponse)({ status:
|
|
126
|
+
(0, swagger_1.ApiResponse)({ status: 200, description: 'Stato del gruppo aggiornato con successo', type: Dtos_1.ActionResponse }),
|
|
127
|
+
(0, swagger_1.ApiResponse)({ status: 400, description: 'Errore di validazione nei dati inviati', type: Dtos_1.ErrorResponse }),
|
|
128
|
+
(0, swagger_1.ApiResponse)({ status: 401, description: 'Utente non autenticato o token non valido', type: Dtos_1.ErrorResponse }),
|
|
129
|
+
(0, swagger_1.ApiResponse)({ status: 403, description: "Utente non autorizzato ad eseguire l'operazione", type: Dtos_1.ErrorResponse }),
|
|
130
|
+
(0, swagger_1.ApiResponse)({ status: 500, description: 'Errore interno del server', type: Dtos_1.ErrorResponse }),
|
|
136
131
|
(0, common_1.Patch)('groups/:codiceGruppo/enabled'),
|
|
137
132
|
__param(0, (0, common_1.Param)('codiceGruppo')),
|
|
138
133
|
__param(1, (0, common_1.Body)()),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfiguratorController.js","sourceRoot":"","sources":["../../../src/accessi-module/Controllers/ConfiguratorController.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2C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CA/HU,sBAAsB;IAJlC,IAAA,uBAAa,GAAE;IACf,IAAA,iBAAO,EAAC,cAAc,CAAC;IACvB,IAAA,mBAAU,EAAC,sBAAsB,CAAC;IAClC,IAAA,kBAAS,EAAC,6BAAc,CAAC;IAGrB,WAAA,IAAA,eAAM,EAAC,iBAAiB,CAAC,CAAA;6CACL,yBAAW;QACH,yCAAmB;GAJvC,sBAAsB,CAgIlC","sourcesContent":["import {\r\n Body,\r\n Controller,\r\n Inject,\r\n Param,\r\n Patch,\r\n Res,\r\n UseGuards,\r\n Req\r\n} from '@nestjs/common';\r\nimport {\r\n ApiBearerAuth,\r\n ApiBody,\r\n ApiOperation,\r\n ApiParam,\r\n ApiResponse,\r\n ApiTags\r\n} from '@nestjs/swagger';\r\nimport { Request, Response } from 'express';\r\nimport { RestUtilities } from '../../Utilities';\r\nimport { AccessiOptions } from '../AccessiModule';\r\nimport { UpdateEnabledStatusRequest } from '../Dtos';\r\nimport { ConfiguratorService } from '../Services/ConfiguratorService/ConfiguratorService';\r\nimport { UserService } from '../Services/UserService/UserService';\r\nimport { JwtSimpleGuard } from '../jwt/jwt.strategy';\r\n\r\n@ApiBearerAuth()\r\n@ApiTags('Configurator')\r\n@Controller('accessi/configurator')\r\n@UseGuards(JwtSimpleGuard)\r\nexport class ConfiguratorController {\r\n constructor(\r\n @Inject('ACCESSI_OPTIONS') private readonly options: AccessiOptions,\r\n private userService: UserService,\r\n private configuratorService: ConfiguratorService\r\n ) {}\r\n\r\n @ApiOperation({\r\n summary: 'Aggiorna lo stato di abilitazione di un menu',\r\n operationId: 'setMenuEnabled',\r\n })\r\n @ApiParam({\r\n name: 'codiceMenu',\r\n description: 'Codice identificativo del menu da aggiornare',\r\n required: true,\r\n example: 'MNU001',\r\n })\r\n @ApiBody({ type: UpdateEnabledStatusRequest })\r\n @ApiResponse({ status: 200, description: 'Stato del menu aggiornato con successo' })\r\n @ApiResponse({ status: 400, description: 'Errore di validazione nei dati inviati' })\r\n @ApiResponse({ status: 403, description: \"Utente non autorizzato ad eseguire l'operazione\" })\r\n @ApiResponse({ status: 500, description: 'Errore interno del server' })\r\n @Patch('menus/:codiceMenu/enabled')\r\n async setMenuEnabled(\r\n @Param('codiceMenu') codiceMenu: string,\r\n @Body() body: UpdateEnabledStatusRequest,\r\n @Req() req: Request,\r\n @Res() res: Response,\r\n ) {\r\n try {\r\n if (!codiceMenu) throw new Error('Il codice del menu � obbligatorio.');\r\n if (body?.enabled === undefined) throw new Error('Lo stato di abilitazione � obbligatorio.');\r\n\r\n const user = (req as any)?.user;\r\n const codiceUtente = user?.utente?.codiceUtente;\r\n if (!codiceUtente) {\r\n return RestUtilities.sendErrorMessage(\r\n res,\r\n 'Utente non riconosciuto dal token.',\r\n ConfiguratorController.name,\r\n 401,\r\n );\r\n }\r\n\r\n const canConfigure =\r\n user?.utente?.flagAdminConfigurator ||\r\n (await this.userService.isAdminConfigurator(codiceUtente));\r\n if (!canConfigure) {\r\n return RestUtilities.sendErrorMessage(\r\n res,\r\n 'Utente non autorizzato ad aggiornare i menu.',\r\n ConfiguratorController.name,\r\n 403,\r\n );\r\n }\r\n\r\n await this.configuratorService.setMenuEnabled(codiceMenu, body.enabled);\r\n\r\n const action = body.enabled ? 'abilitato' : 'disabilitato';\r\n return RestUtilities.sendOKMessage(\r\n res,\r\n `Il menu ${codiceMenu} � stato ${action} con successo.`,\r\n );\r\n } catch (error) {\r\n return RestUtilities.sendErrorMessage(res, error, ConfiguratorController.name);\r\n }\r\n }\r\n\r\n @ApiOperation({\r\n summary: 'Aggiorna lo stato di abilitazione di un gruppo menu',\r\n operationId: 'setGroupEnabled',\r\n })\r\n @ApiParam({\r\n name: 'codiceGruppo',\r\n description: 'Codice identificativo del gruppo da aggiornare',\r\n required: true,\r\n example: 'GRP01',\r\n })\r\n @ApiBody({ type: UpdateEnabledStatusRequest })\r\n @ApiResponse({ status: 200, description: 'Stato del gruppo aggiornato con successo' })\r\n @ApiResponse({ status: 400, description: 'Errore di validazione nei dati inviati' })\r\n @ApiResponse({ status: 403, description: \"Utente non autorizzato ad eseguire l'operazione\" })\r\n @ApiResponse({ status: 500, description: 'Errore interno del server' })\r\n @Patch('groups/:codiceGruppo/enabled')\r\n async setGroupEnabled(\r\n @Param('codiceGruppo') codiceGruppo: string,\r\n @Body() body: UpdateEnabledStatusRequest,\r\n @Req() req: Request,\r\n @Res() res: Response,\r\n ) {\r\n try {\r\n if (!codiceGruppo) throw new Error('Il codice del gruppo � obbligatorio.');\r\n if (body?.enabled === undefined) throw new Error('Lo stato di abilitazione � obbligatorio.');\r\n\r\n const user = (req as any)?.user;\r\n const codiceUtente = user?.utente?.codiceUtente;\r\n if (!codiceUtente) {\r\n return RestUtilities.sendErrorMessage(\r\n res,\r\n 'Utente non riconosciuto dal token.',\r\n ConfiguratorController.name,\r\n 401,\r\n );\r\n }\r\n\r\n const canConfigure =\r\n user?.utente?.flagAdminConfigurator ||\r\n (await this.userService.isAdminConfigurator(codiceUtente));\r\n if (!canConfigure) {\r\n return RestUtilities.sendErrorMessage(\r\n res,\r\n 'Utente non autorizzato ad aggiornare i gruppi menu.',\r\n ConfiguratorController.name,\r\n 403,\r\n );\r\n }\r\n\r\n await this.configuratorService.setGroupEnabled(codiceGruppo, body.enabled);\r\n\r\n const action = body.enabled ? 'abilitato' : 'disabilitato';\r\n return RestUtilities.sendOKMessage(\r\n res,\r\n `Il gruppo ${codiceGruppo} � stato ${action} con successo.`,\r\n );\r\n } catch (error) {\r\n return RestUtilities.sendErrorMessage(res, error, ConfiguratorController.name);\r\n }\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"ConfiguratorController.js","sourceRoot":"","sources":["../../../src/accessi-module/Controllers/ConfiguratorController.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CASwB;AACxB,6CAOyB;AAEzB,+CAAgD;AAEhD,kCAAoF;AACpF,6FAA0F;AAC1F,qEAAkE;AAClE,sDAAqD;AACrD,6DAAwE;AAMjE,IA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W;QACH,yCAAmB;GAJvC,sBAAsB,CAkHlC","sourcesContent":["import {\n Body,\n Controller,\n Inject,\n Param,\n Patch,\n Req,\n Res,\n UseGuards,\n} from '@nestjs/common';\nimport {\n ApiBearerAuth,\n ApiBody,\n ApiOperation,\n ApiParam,\n ApiResponse,\n ApiTags,\n} from '@nestjs/swagger';\nimport { Request, Response } from 'express';\nimport { RestUtilities } from '../../Utilities';\nimport { AccessiOptions } from '../AccessiModule';\nimport { ActionResponse, ErrorResponse, UpdateEnabledStatusRequest } from '../Dtos';\nimport { ConfiguratorService } from '../Services/ConfiguratorService/ConfiguratorService';\nimport { UserService } from '../Services/UserService/UserService';\nimport { JwtSimpleGuard } from '../jwt/jwt.strategy';\nimport { getAuthenticatedAccessiUser } from '../security/accessControl';\n\n@ApiBearerAuth()\n@ApiTags('Configurator')\n@Controller('accessi/configurator')\n@UseGuards(JwtSimpleGuard)\nexport class ConfiguratorController {\n constructor(\n @Inject('ACCESSI_OPTIONS') private readonly options: AccessiOptions,\n private userService: UserService,\n private configuratorService: ConfiguratorService,\n ) {}\n\n @ApiOperation({\n summary: 'Aggiorna lo stato di abilitazione di un menu',\n operationId: 'setMenuEnabled',\n })\n @ApiParam({\n name: 'codiceMenu',\n description: 'Codice identificativo del menu da aggiornare',\n required: true,\n example: 'MNU001',\n })\n @ApiBody({ type: UpdateEnabledStatusRequest })\n @ApiResponse({ status: 200, description: 'Stato del menu aggiornato con successo', type: ActionResponse })\n @ApiResponse({ status: 400, description: 'Errore di validazione nei dati inviati', type: ErrorResponse })\n @ApiResponse({ status: 401, description: 'Utente non autenticato o token non valido', type: ErrorResponse })\n @ApiResponse({ status: 403, description: \"Utente non autorizzato ad eseguire l'operazione\", type: ErrorResponse })\n @ApiResponse({ status: 500, description: 'Errore interno del server', type: ErrorResponse })\n @Patch('menus/:codiceMenu/enabled')\n async setMenuEnabled(\n @Param('codiceMenu') codiceMenu: string,\n @Body() body: UpdateEnabledStatusRequest,\n @Req() req: Request,\n @Res() res: Response,\n ) {\n try {\n if (!codiceMenu) throw new Error('Il codice del menu e obbligatorio.');\n if (body?.enabled === undefined) throw new Error('Lo stato di abilitazione e obbligatorio.');\n\n const authenticatedUser = getAuthenticatedAccessiUser(req);\n\n const canConfigure =\n authenticatedUser.flagSuper ||\n authenticatedUser.flagAdminConfigurator ||\n (await this.userService.isAdminConfigurator(authenticatedUser.codiceUtente));\n if (!canConfigure) {\n return RestUtilities.sendErrorMessage(\n res,\n 'Utente non autorizzato ad aggiornare i menu.',\n ConfiguratorController.name,\n 403,\n );\n }\n\n await this.configuratorService.setMenuEnabled(codiceMenu, body.enabled);\n\n const action = body.enabled ? 'abilitato' : 'disabilitato';\n return RestUtilities.sendOKMessage(\n res,\n `Il menu ${codiceMenu} e stato ${action} con successo.`,\n );\n } catch (error) {\n return RestUtilities.sendErrorMessage(res, error, ConfiguratorController.name);\n }\n }\n\n @ApiOperation({\n summary: 'Aggiorna lo stato di abilitazione di un gruppo menu',\n operationId: 'setGroupEnabled',\n })\n @ApiParam({\n name: 'codiceGruppo',\n description: 'Codice identificativo del gruppo da aggiornare',\n required: true,\n example: 'GRP01',\n })\n @ApiBody({ type: UpdateEnabledStatusRequest })\n @ApiResponse({ status: 200, description: 'Stato del gruppo aggiornato con successo', type: ActionResponse })\n @ApiResponse({ status: 400, description: 'Errore di validazione nei dati inviati', type: ErrorResponse })\n @ApiResponse({ status: 401, description: 'Utente non autenticato o token non valido', type: ErrorResponse })\n @ApiResponse({ status: 403, description: \"Utente non autorizzato ad eseguire l'operazione\", type: ErrorResponse })\n @ApiResponse({ status: 500, description: 'Errore interno del server', type: ErrorResponse })\n @Patch('groups/:codiceGruppo/enabled')\n async setGroupEnabled(\n @Param('codiceGruppo') codiceGruppo: string,\n @Body() body: UpdateEnabledStatusRequest,\n @Req() req: Request,\n @Res() res: Response,\n ) {\n try {\n if (!codiceGruppo) throw new Error('Il codice del gruppo e obbligatorio.');\n if (body?.enabled === undefined) throw new Error('Lo stato di abilitazione e obbligatorio.');\n\n const authenticatedUser = getAuthenticatedAccessiUser(req);\n\n const canConfigure =\n authenticatedUser.flagSuper ||\n authenticatedUser.flagAdminConfigurator ||\n (await this.userService.isAdminConfigurator(authenticatedUser.codiceUtente));\n if (!canConfigure) {\n return RestUtilities.sendErrorMessage(\n res,\n 'Utente non autorizzato ad aggiornare i gruppi menu.',\n ConfiguratorController.name,\n 403,\n );\n }\n\n await this.configuratorService.setGroupEnabled(codiceGruppo, body.enabled);\n\n const action = body.enabled ? 'abilitato' : 'disabilitato';\n return RestUtilities.sendOKMessage(\n res,\n `Il gruppo ${codiceGruppo} e stato ${action} con successo.`,\n );\n } catch (error) {\n return RestUtilities.sendErrorMessage(res, error, ConfiguratorController.name);\n }\n }\n}\n"]}
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { Request, Response } from 'express';
|
|
2
2
|
import { AccessiOptions } from '../AccessiModule';
|
|
3
|
+
import { SendResetPasswordEmailRequest } from '../Dtos';
|
|
3
4
|
import { EmailService } from '../Services/EmailService/EmailService';
|
|
4
5
|
export declare class EmailController {
|
|
5
6
|
private readonly accessiOptions;
|
|
6
7
|
private readonly emailService;
|
|
7
8
|
constructor(accessiOptions: AccessiOptions, emailService: EmailService);
|
|
8
9
|
serveResetPasswordPage(res: Response, token: string, returnUrl?: string): Promise<void>;
|
|
9
|
-
sendPasswordResetEmail(request: Request, sendResetPasswordData:
|
|
10
|
-
email: string;
|
|
11
|
-
htmlMail?: string;
|
|
12
|
-
}, res: Response): Promise<Response<any, Record<string, any>>>;
|
|
10
|
+
sendPasswordResetEmail(request: Request, sendResetPasswordData: SendResetPasswordEmailRequest, res: Response): Promise<Response<any, Record<string, any>>>;
|
|
13
11
|
}
|
|
@@ -27,6 +27,7 @@ const common_1 = require("@nestjs/common");
|
|
|
27
27
|
const swagger_1 = require("@nestjs/swagger");
|
|
28
28
|
const path_1 = require("path");
|
|
29
29
|
const Utilities_1 = require("../../Utilities");
|
|
30
|
+
const Dtos_1 = require("../Dtos");
|
|
30
31
|
const EmailService_1 = require("../Services/EmailService/EmailService");
|
|
31
32
|
const publicAuthRateLimit_1 = require("../security/publicAuthRateLimit");
|
|
32
33
|
let EmailController = EmailController_1 = class EmailController {
|
|
@@ -81,28 +82,23 @@ __decorate([
|
|
|
81
82
|
summary: 'Invia una e-mail per il reset della password',
|
|
82
83
|
operationId: 'sendPasswordResetEmail',
|
|
83
84
|
}),
|
|
84
|
-
(0, swagger_1.ApiBody)({
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
description: "L'email dell'utente che richiede il reset",
|
|
90
|
-
},
|
|
91
|
-
},
|
|
92
|
-
required: ['email'],
|
|
93
|
-
},
|
|
85
|
+
(0, swagger_1.ApiBody)({ type: Dtos_1.SendResetPasswordEmailRequest }),
|
|
86
|
+
(0, swagger_1.ApiResponse)({
|
|
87
|
+
status: 200,
|
|
88
|
+
description: "L'email di reset e stata gestita con successo",
|
|
89
|
+
type: Dtos_1.ActionResponse,
|
|
94
90
|
}),
|
|
95
|
-
(0, swagger_1.ApiResponse)({ status: 200, description: "L'email di reset e stata gestita con successo" }),
|
|
96
91
|
(0, swagger_1.ApiResponse)({
|
|
97
92
|
status: 500,
|
|
98
93
|
description: "Errore interno durante l'invio dell'email",
|
|
94
|
+
type: Dtos_1.ErrorResponse,
|
|
99
95
|
}),
|
|
100
96
|
(0, common_1.Post)('send-reset-password-email'),
|
|
101
97
|
__param(0, (0, common_1.Req)()),
|
|
102
98
|
__param(1, (0, common_1.Body)()),
|
|
103
99
|
__param(2, (0, common_1.Res)()),
|
|
104
100
|
__metadata("design:type", Function),
|
|
105
|
-
__metadata("design:paramtypes", [Object,
|
|
101
|
+
__metadata("design:paramtypes", [Object, Dtos_1.SendResetPasswordEmailRequest, Object]),
|
|
106
102
|
__metadata("design:returntype", Promise)
|
|
107
103
|
], EmailController.prototype, "sendPasswordResetEmail", null);
|
|
108
104
|
exports.EmailController = EmailController = EmailController_1 = __decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EmailController.js","sourceRoot":"","sources":["../../../src/accessi-module/Controllers/EmailController.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA6F;AAC7F,6CAAkG;AAElG,+BAA4B;AAC5B,+CAAgD;AAEhD,wEAAqE;AACrE,yEAGyC;AAIlC,IAAM,eAAe,uBAArB,MAAM,eAAe;IAC1B,YAC8C,cAA8B,EACzD,YAA0B;QADC,mBAAc,GAAd,cAAc,CAAgB;QACzD,iBAAY,GAAZ,YAAY,CAAc;IAC1C,CAAC;IAcE,sBAAsB,CACnB,GAAa,EACJ,KAAa,EACT,SAAkB;;YAEtC,OAAO,GAAG,CAAC,QAAQ,CAAC,IAAA,WAAI,EAAC,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,qBAAqB,CAAC,CAAC,CAAC;QAC7E,CAAC;KAAA;
|
|
1
|
+
{"version":3,"file":"EmailController.js","sourceRoot":"","sources":["../../../src/accessi-module/Controllers/EmailController.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA6F;AAC7F,6CAAkG;AAElG,+BAA4B;AAC5B,+CAAgD;AAEhD,kCAAuF;AACvF,wEAAqE;AACrE,yEAGyC;AAIlC,IAAM,eAAe,uBAArB,MAAM,eAAe;IAC1B,YAC8C,cAA8B,EACzD,YAA0B;QADC,mBAAc,GAAd,cAAc,CAAgB;QACzD,iBAAY,GAAZ,YAAY,CAAc;IAC1C,CAAC;IAcE,sBAAsB,CACnB,GAAa,EACJ,KAAa,EACT,SAAkB;;YAEtC,OAAO,GAAG,CAAC,QAAQ,CAAC,IAAA,WAAI,EAAC,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,qBAAqB,CAAC,CAAC,CAAC;QAC7E,CAAC;KAAA;IAkBK,sBAAsB,CACnB,OAAgB,EACf,qBAAoD,EACrD,GAAa;;YAEpB,IAAI,CAAC;gBACH,MAAM,iBAA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;;;;6DAGpB;AAkBK;IAhBL,IAAA,sBAAY,EAAC;QACZ,OAAO,EAAE,8CAA8C;QACvD,WAAW,EAAE,wBAAwB;KACtC,CAAC;IACD,IAAA,iBAAO,EAAC,EAAE,IAAI,EAAE,oCAA6B,EAAE,CAAC;IAChD,IAAA,qBAAW,EAAC;QACX,MAAM,EAAE,GAAG;QACX,WAAW,EAAE,+CAA+C;QAC5D,IAAI,EAAE,qBAAc;KACrB,CAAC;IACD,IAAA,qBAAW,EAAC;QACX,MAAM,EAAE,GAAG;QACX,WAAW,EAAE,2CAA2C;QACxD,IAAI,EAAE,oBAAa;KACpB,CAAC;IACD,IAAA,aAAI,EAAC,2BAA2B,CAAC;IAE/B,WAAA,IAAA,YAAG,GAAE,CAAA;IACL,WAAA,IAAA,aAAI,GAAE,CAAA;IACN,WAAA,IAAA,YAAG,GAAE,CAAA;;6CADyB,oCAA6B;;6DAsB7D;0BAlEU,eAAe;IAF3B,IAAA,iBAAO,EAAC,OAAO,CAAC;IAChB,IAAA,mBAAU,EAAC,eAAe,CAAC;IAGvB,WAAA,IAAA,eAAM,EAAC,iBAAiB,CAAC,CAAA;6CACK,2BAAY;GAHlC,eAAe,CAmE3B","sourcesContent":["import { Body, Controller, Get, Inject, Param, Post, Query, Req, Res } from '@nestjs/common';\nimport { ApiBody, ApiOperation, ApiParam, ApiQuery, ApiResponse, ApiTags } from '@nestjs/swagger';\nimport { Request, Response } from 'express';\nimport { join } from 'path';\nimport { RestUtilities } from '../../Utilities';\nimport { AccessiOptions } from '../AccessiModule';\nimport { ActionResponse, ErrorResponse, SendResetPasswordEmailRequest } from '../Dtos';\nimport { EmailService } from '../Services/EmailService/EmailService';\nimport {\n checkPublicAuthRateLimit,\n sendPublicAuthRateLimitExceeded,\n} from '../security/publicAuthRateLimit';\n\n@ApiTags('Email')\n@Controller('accessi/email')\nexport class EmailController {\n constructor(\n @Inject('ACCESSI_OPTIONS') private readonly accessiOptions: AccessiOptions,\n private readonly emailService: EmailService,\n ) {}\n\n @ApiOperation({\n summary: 'Serve una pagina per il reset della password',\n operationId: 'serveResetPasswordPage',\n })\n @ApiParam({ name: 'token', description: 'Token per il reset della password', required: true })\n @ApiQuery({\n name: 'returnUrl',\n description: 'Url di ritorno della pagina',\n required: false,\n })\n @ApiResponse({ status: 200, description: 'Pagina di reset password servita con successo' })\n @Get('reset-password-page/:token')\n async serveResetPasswordPage(\n @Res() res: Response,\n @Param('token') token: string,\n @Query('returnUrl') returnUrl?: string,\n ) {\n return res.sendFile(join(__dirname, '..', 'Views', 'reset-password.html'));\n }\n\n @ApiOperation({\n summary: 'Invia una e-mail per il reset della password',\n operationId: 'sendPasswordResetEmail',\n })\n @ApiBody({ type: SendResetPasswordEmailRequest })\n @ApiResponse({\n status: 200,\n description: \"L'email di reset e stata gestita con successo\",\n type: ActionResponse,\n })\n @ApiResponse({\n status: 500,\n description: \"Errore interno durante l'invio dell'email\",\n type: ErrorResponse,\n })\n @Post('send-reset-password-email')\n async sendPasswordResetEmail(\n @Req() request: Request,\n @Body() sendResetPasswordData: SendResetPasswordEmailRequest,\n @Res() res: Response,\n ) {\n try {\n const rateLimitDecision = checkPublicAuthRateLimit(\n this.accessiOptions,\n 'passwordResetEmail',\n request,\n [sendResetPasswordData?.email],\n );\n if (!rateLimitDecision.allowed) {\n return sendPublicAuthRateLimitExceeded(res, rateLimitDecision.retryAfterSeconds);\n }\n\n await this.emailService.sendPasswordResetEmail(sendResetPasswordData.email);\n return RestUtilities.sendOKMessage(\n res,\n \"Se l'account esiste, l'email di reset e stata inoltrata al destinatario.\",\n );\n } catch (error) {\n return RestUtilities.sendErrorMessage(res, error, EmailController.name);\n }\n }\n}\n"]}
|
|
@@ -26,6 +26,7 @@ exports.FiltriController = void 0;
|
|
|
26
26
|
const common_1 = require("@nestjs/common");
|
|
27
27
|
const swagger_1 = require("@nestjs/swagger");
|
|
28
28
|
const Utilities_1 = require("../../Utilities");
|
|
29
|
+
const BaseResponse_1 = require("../Dtos/BaseResponse");
|
|
29
30
|
const Dtos_1 = require("../Dtos");
|
|
30
31
|
const TipoFiltro_1 = require("../Dtos/TipoFiltro");
|
|
31
32
|
const FiltriService_1 = require("../Services/FiltriService/FiltriService");
|
|
@@ -98,6 +99,7 @@ __decorate([
|
|
|
98
99
|
(0, swagger_1.ApiResponse)({
|
|
99
100
|
status: 500,
|
|
100
101
|
description: 'Errore interno durante il recupero dei tipi di filtri',
|
|
102
|
+
type: BaseResponse_1.ErrorResponse,
|
|
101
103
|
}),
|
|
102
104
|
__param(0, (0, common_1.Res)()),
|
|
103
105
|
__metadata("design:type", Function),
|
|
@@ -116,6 +118,21 @@ __decorate([
|
|
|
116
118
|
description: "Lista dei filtri dell'utente recuperata con successo",
|
|
117
119
|
type: Dtos_1.GetFiltriUtenteResponse,
|
|
118
120
|
}),
|
|
121
|
+
(0, swagger_1.ApiResponse)({
|
|
122
|
+
status: 400,
|
|
123
|
+
description: 'Errore nella richiesta.',
|
|
124
|
+
type: BaseResponse_1.ErrorResponse,
|
|
125
|
+
}),
|
|
126
|
+
(0, swagger_1.ApiResponse)({
|
|
127
|
+
status: 403,
|
|
128
|
+
description: 'Operazione non autorizzata.',
|
|
129
|
+
type: BaseResponse_1.ErrorResponse,
|
|
130
|
+
}),
|
|
131
|
+
(0, swagger_1.ApiResponse)({
|
|
132
|
+
status: 500,
|
|
133
|
+
description: 'Errore interno del server.',
|
|
134
|
+
type: BaseResponse_1.ErrorResponse,
|
|
135
|
+
}),
|
|
119
136
|
__param(0, (0, common_1.Req)()),
|
|
120
137
|
__param(1, (0, common_1.Res)()),
|
|
121
138
|
__param(2, (0, common_1.Query)()),
|
|
@@ -133,10 +150,22 @@ __decorate([
|
|
|
133
150
|
(0, swagger_1.ApiResponse)({
|
|
134
151
|
status: 200,
|
|
135
152
|
description: 'Filtri utente salvati con successo',
|
|
153
|
+
type: BaseResponse_1.ActionResponse,
|
|
154
|
+
}),
|
|
155
|
+
(0, swagger_1.ApiResponse)({
|
|
156
|
+
status: 400,
|
|
157
|
+
description: 'Errore di validazione nei dati inviati.',
|
|
158
|
+
type: BaseResponse_1.ErrorResponse,
|
|
159
|
+
}),
|
|
160
|
+
(0, swagger_1.ApiResponse)({
|
|
161
|
+
status: 403,
|
|
162
|
+
description: 'Operazione non autorizzata.',
|
|
163
|
+
type: BaseResponse_1.ErrorResponse,
|
|
136
164
|
}),
|
|
137
165
|
(0, swagger_1.ApiResponse)({
|
|
138
166
|
status: 500,
|
|
139
167
|
description: 'Errore interno durante il salvataggio dei filtri utente',
|
|
168
|
+
type: BaseResponse_1.ErrorResponse,
|
|
140
169
|
}),
|
|
141
170
|
__param(0, (0, common_1.Req)()),
|
|
142
171
|
__param(1, (0, common_1.Res)()),
|