emilsoftware-utilities 2.0.0-dev.10 → 2.0.0-dev.12
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/Orm.d.ts +2 -0
- package/dist/Orm.js +27 -2
- package/dist/Orm.js.map +1 -1
- package/dist/Utilities.js +1 -0
- package/dist/Utilities.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 +16 -14
- 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 +27 -25
- 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/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/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/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/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/UserDto.js +5 -1
- package/dist/accessi-module/Dtos/UserDto.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/FiltriService/FiltriService.js +0 -7
- package/dist/accessi-module/Services/FiltriService/FiltriService.js.map +1 -1
- package/dist/accessi-module/Services/UserService/UserService.js +2 -100
- package/dist/accessi-module/Services/UserService/UserService.js.map +1 -1
- package/dist/accessi-module/index.js +2 -0
- package/dist/accessi-module/index.js.map +1 -1
- package/dist/emilsoftware-utilities-2.0.0-dev.12.tgz +0 -0
- package/dist/firebird-compat.d.ts +1 -0
- package/dist/firebird-compat.js +2 -2
- package/dist/firebird-compat.js.map +1 -1
- package/dist/swagger/SwaggerConfig.d.ts +1 -0
- package/dist/swagger/SwaggerConfig.js +16 -5
- package/dist/swagger/SwaggerConfig.js.map +1 -1
- package/package.json +1 -1
- package/dist/emilsoftware-utilities-2.0.0-dev.10.tgz +0 -0
|
@@ -41,9 +41,9 @@ let ConfiguratorController = ConfiguratorController_1 = class ConfiguratorContro
|
|
|
41
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
|
|
46
|
+
throw new Error('Lo stato di abilitazione e obbligatorio.');
|
|
47
47
|
const user = req === null || req === void 0 ? void 0 : req.user;
|
|
48
48
|
const codiceUtente = (_a = user === null || user === void 0 ? void 0 : user.utente) === null || _a === void 0 ? void 0 : _a.codiceUtente;
|
|
49
49
|
if (!codiceUtente) {
|
|
@@ -56,7 +56,7 @@ let ConfiguratorController = ConfiguratorController_1 = class ConfiguratorContro
|
|
|
56
56
|
}
|
|
57
57
|
yield this.configuratorService.setMenuEnabled(codiceMenu, body.enabled);
|
|
58
58
|
const action = body.enabled ? 'abilitato' : 'disabilitato';
|
|
59
|
-
return Utilities_1.RestUtilities.sendOKMessage(res, `Il menu ${codiceMenu}
|
|
59
|
+
return Utilities_1.RestUtilities.sendOKMessage(res, `Il menu ${codiceMenu} e stato ${action} con successo.`);
|
|
60
60
|
}
|
|
61
61
|
catch (error) {
|
|
62
62
|
return Utilities_1.RestUtilities.sendErrorMessage(res, error, ConfiguratorController_1.name);
|
|
@@ -68,9 +68,9 @@ let ConfiguratorController = ConfiguratorController_1 = class ConfiguratorContro
|
|
|
68
68
|
var _a, _b;
|
|
69
69
|
try {
|
|
70
70
|
if (!codiceGruppo)
|
|
71
|
-
throw new Error('Il codice del gruppo
|
|
71
|
+
throw new Error('Il codice del gruppo e obbligatorio.');
|
|
72
72
|
if ((body === null || body === void 0 ? void 0 : body.enabled) === undefined)
|
|
73
|
-
throw new Error('Lo stato di abilitazione
|
|
73
|
+
throw new Error('Lo stato di abilitazione e obbligatorio.');
|
|
74
74
|
const user = req === null || req === void 0 ? void 0 : req.user;
|
|
75
75
|
const codiceUtente = (_a = user === null || user === void 0 ? void 0 : user.utente) === null || _a === void 0 ? void 0 : _a.codiceUtente;
|
|
76
76
|
if (!codiceUtente) {
|
|
@@ -83,7 +83,7 @@ let ConfiguratorController = ConfiguratorController_1 = class ConfiguratorContro
|
|
|
83
83
|
}
|
|
84
84
|
yield this.configuratorService.setGroupEnabled(codiceGruppo, body.enabled);
|
|
85
85
|
const action = body.enabled ? 'abilitato' : 'disabilitato';
|
|
86
|
-
return Utilities_1.RestUtilities.sendOKMessage(res, `Il gruppo ${codiceGruppo}
|
|
86
|
+
return Utilities_1.RestUtilities.sendOKMessage(res, `Il gruppo ${codiceGruppo} e stato ${action} con successo.`);
|
|
87
87
|
}
|
|
88
88
|
catch (error) {
|
|
89
89
|
return Utilities_1.RestUtilities.sendErrorMessage(res, error, ConfiguratorController_1.name);
|
|
@@ -104,10 +104,11 @@ __decorate([
|
|
|
104
104
|
example: 'MNU001',
|
|
105
105
|
}),
|
|
106
106
|
(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:
|
|
107
|
+
(0, swagger_1.ApiResponse)({ status: 200, description: 'Stato del menu aggiornato con successo', type: Dtos_1.ActionResponse }),
|
|
108
|
+
(0, swagger_1.ApiResponse)({ status: 400, description: 'Errore di validazione nei dati inviati', type: Dtos_1.ErrorResponse }),
|
|
109
|
+
(0, swagger_1.ApiResponse)({ status: 401, description: 'Utente non autenticato o token non valido', type: Dtos_1.ErrorResponse }),
|
|
110
|
+
(0, swagger_1.ApiResponse)({ status: 403, description: "Utente non autorizzato ad eseguire l'operazione", type: Dtos_1.ErrorResponse }),
|
|
111
|
+
(0, swagger_1.ApiResponse)({ status: 500, description: 'Errore interno del server', type: Dtos_1.ErrorResponse }),
|
|
111
112
|
(0, common_1.Patch)('menus/:codiceMenu/enabled'),
|
|
112
113
|
__param(0, (0, common_1.Param)('codiceMenu')),
|
|
113
114
|
__param(1, (0, common_1.Body)()),
|
|
@@ -129,10 +130,11 @@ __decorate([
|
|
|
129
130
|
example: 'GRP01',
|
|
130
131
|
}),
|
|
131
132
|
(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:
|
|
133
|
+
(0, swagger_1.ApiResponse)({ status: 200, description: 'Stato del gruppo aggiornato con successo', type: Dtos_1.ActionResponse }),
|
|
134
|
+
(0, swagger_1.ApiResponse)({ status: 400, description: 'Errore di validazione nei dati inviati', type: Dtos_1.ErrorResponse }),
|
|
135
|
+
(0, swagger_1.ApiResponse)({ status: 401, description: 'Utente non autenticato o token non valido', type: Dtos_1.ErrorResponse }),
|
|
136
|
+
(0, swagger_1.ApiResponse)({ status: 403, description: "Utente non autorizzato ad eseguire l'operazione", type: Dtos_1.ErrorResponse }),
|
|
137
|
+
(0, swagger_1.ApiResponse)({ status: 500, description: 'Errore interno del server', type: Dtos_1.ErrorResponse }),
|
|
136
138
|
(0, common_1.Patch)('groups/:codiceGruppo/enabled'),
|
|
137
139
|
__param(0, (0, common_1.Param)('codiceGruppo')),
|
|
138
140
|
__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,2CASwB;AACxB,6CAOyB;AAEzB,+CAAgD;AAEhD,kCAAqD;AACrD,6FAA0F;AAC1F,qEAAkE;AAClE,sDAAqD;AAM9C,IAAM,sBAAsB,8BAA5B,MAAM,sBAAsB;IACjC,YAC8C,OAAuB,EAC3D,WAAwB,EACxB,mBAAwC;QAFJ,YAAO,GAAP,OAAO,CAAgB;QAC3D,gBAAW,GAAX,WAAW,CAAa;QACxB,wBAAmB,GAAnB,mBAAmB,CAAqB;IAC/C,CAAC;IAkBE,cAAc,CACG,UAAkB,EAC/B,IAAgC,EACjC,GAAY,EACZ,GAAa;;;YAEpB,IAAI,CAAC;gBACH,IAAI,CAAC,UAAU;oBAAE,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;gBACvE,IAAI,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,OAAO,MAAK,SAAS;oBAAE,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;gBAE7F,MAAM,IAAI,GAAI,GAAW,aAAX,GAAG,uBAAH,GAAG,CAAU,IAAI,CAAC;gBAChC,MAAM,YAAY,GAAG,MAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,MAAM,0CAAE,YAAY,CAAC;gBAChD,IAAI,CAAC,YAAY,EAAE,CAAC;oBAClB,OAAO,yBAAa,CAAC,gBAAgB,CACnC,GAAG,EACH,oCAAoC,EACpC,wBAAsB,CAAC,IAAI,EA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EAAE,iDAAiD,EAAE,CAAC;IAC5F,IAAA,qBAAW,EAAC,EAAE,MAAM,EAAE,GAAG,EAAE,WAAW,EAAE,2BAA2B,EAAE,CAAC;IACtE,IAAA,cAAK,EAAC,8BAA8B,CAAC;IAEnC,WAAA,IAAA,cAAK,EAAC,cAAc,CAAC,CAAA;IACrB,WAAA,IAAA,aAAI,GAAE,CAAA;IACN,WAAA,IAAA,YAAG,GAAE,CAAA;IACL,WAAA,IAAA,YAAG,GAAE,CAAA;;6CAFQ,iCAA0B;;6DAyCzC;iCA/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 {\n Body,\n Controller,\n Inject,\n Param,\n Patch,\n Res,\n UseGuards,\n Req\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 { UpdateEnabledStatusRequest } from '../Dtos';\nimport { ConfiguratorService } from '../Services/ConfiguratorService/ConfiguratorService';\nimport { UserService } from '../Services/UserService/UserService';\nimport { JwtSimpleGuard } from '../jwt/jwt.strategy';\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' })\n @ApiResponse({ status: 400, description: 'Errore di validazione nei dati inviati' })\n @ApiResponse({ status: 403, description: \"Utente non autorizzato ad eseguire l'operazione\" })\n @ApiResponse({ status: 500, description: 'Errore interno del server' })\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 � obbligatorio.');\n if (body?.enabled === undefined) throw new Error('Lo stato di abilitazione � obbligatorio.');\n\n const user = (req as any)?.user;\n const codiceUtente = user?.utente?.codiceUtente;\n if (!codiceUtente) {\n return RestUtilities.sendErrorMessage(\n res,\n 'Utente non riconosciuto dal token.',\n ConfiguratorController.name,\n 401,\n );\n }\n\n const canConfigure =\n user?.utente?.flagAdminConfigurator ||\n (await this.userService.isAdminConfigurator(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} � 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' })\n @ApiResponse({ status: 400, description: 'Errore di validazione nei dati inviati' })\n @ApiResponse({ status: 403, description: \"Utente non autorizzato ad eseguire l'operazione\" })\n @ApiResponse({ status: 500, description: 'Errore interno del server' })\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 � obbligatorio.');\n if (body?.enabled === undefined) throw new Error('Lo stato di abilitazione � obbligatorio.');\n\n const user = (req as any)?.user;\n const codiceUtente = user?.utente?.codiceUtente;\n if (!codiceUtente) {\n return RestUtilities.sendErrorMessage(\n res,\n 'Utente non riconosciuto dal token.',\n ConfiguratorController.name,\n 401,\n );\n }\n\n const canConfigure =\n user?.utente?.flagAdminConfigurator ||\n (await this.userService.isAdminConfigurator(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} � stato ${action} con successo.`,\n );\n } catch (error) {\n return RestUtilities.sendErrorMessage(res, error, ConfiguratorController.name);\n }\n }\n}\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;AAM9C,IAAM,sBAAsB,8BAA5B,MAAM,sBAAsB;IACjC,YAC8C,OAAuB,EA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BAA2B,EAAE,IAAI,EAAE,oBAAa,EAAE,CAAC;IAC3F,IAAA,cAAK,EAAC,8BAA8B,CAAC;IAEnC,WAAA,IAAA,cAAK,EAAC,cAAc,CAAC,CAAA;IACrB,WAAA,IAAA,aAAI,GAAE,CAAA;IACN,WAAA,IAAA,YAAG,GAAE,CAAA;IACL,WAAA,IAAA,YAAG,GAAE,CAAA;;6CAFQ,iCAA0B;;6DAyCzC;iCAjIU,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,CAkIlC","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';\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 user = (req as any)?.user;\n const codiceUtente = user?.utente?.codiceUtente;\n if (!codiceUtente) {\n return RestUtilities.sendErrorMessage(\n res,\n 'Utente non riconosciuto dal token.',\n ConfiguratorController.name,\n 401,\n );\n }\n\n const canConfigure =\n user?.utente?.flagAdminConfigurator ||\n (await this.userService.isAdminConfigurator(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 user = (req as any)?.user;\n const codiceUtente = user?.utente?.codiceUtente;\n if (!codiceUtente) {\n return RestUtilities.sendErrorMessage(\n res,\n 'Utente non riconosciuto dal token.',\n ConfiguratorController.name,\n 401,\n );\n }\n\n const canConfigure =\n user?.utente?.flagAdminConfigurator ||\n (await this.userService.isAdminConfigurator(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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AAA,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)()),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FiltriController.js","sourceRoot":"","sources":["../../../src/accessi-module/Controllers/FiltriController.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAAiG;AACjG,6CAAoF;AAEpF,+CAAgD;AAEhD,kCAAwF;AACxF,mDAAuD;AACvD,2EAAwE;AACxE,sDAAqD;AACrD,6DAImC;AAM5B,IAAM,gBAAgB,wBAAtB,MAAM,gBAAgB;IAC3B,YACmB,aAA4B,EACD,OAAuB;QADlD,kBAAa,GAAb,aAAa,CAAe;QACD,YAAO,GAAP,OAAO,CAAgB;IAClE,CAAC;
|
|
1
|
+
{"version":3,"file":"FiltriController.js","sourceRoot":"","sources":["../../../src/accessi-module/Controllers/FiltriController.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAAiG;AACjG,6CAAoF;AAEpF,+CAAgD;AAEhD,uDAAqE;AACrE,kCAAwF;AACxF,mDAAuD;AACvD,2EAAwE;AACxE,sDAAqD;AACrD,6DAImC;AAM5B,IAAM,gBAAgB,wBAAtB,MAAM,gBAAgB;IAC3B,YACmB,aAA4B,EACD,OAAuB;QADlD,kBAAa,GAAb,aAAa,CAAe;QACD,YAAO,GAAP,OAAO,CAAgB;IAClE,CAAC;IAkBE,aAAa,CAAQ,GAAa;;YACtC,IAAI,CAAC;gBACH,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,aAAa,EAAE,CAAC;gBAC1D,OAAO,yBAAa,CAAC,gBAAgB,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;YACvD,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO,yBAAa,CAAC,gBAAgB,CAAC,GAAG,EAAE,KAAK,EAAE,kBAAgB,CAAC,IAAI,CAAC,CAAC;YAC3E,CAAC;QACH,CAAC;KAAA;IA4BK,eAAe,CACZ,OAAgB,EAChB,GAAa,EACX,GAA2B;;YAEpC,IAAI,CAAC;gBACH,MAAM,iBAAiB,GAAG,IAAA,2CAA2B,EAAC,OAAO,CAAC,CAAC;gBAC/D,MAAM,cAAc,GAAG,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,MAAM,CAAC;gBAEnC,IAAI,cAAc,KAAK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,QAAQ,CAAC;IACd,IAAA,sBAAY,EAAC;QACZ,WAAW,EAAE,kBAAkB;QAC/B,OAAO,EAAE,4CAA4C;QACrD,WAAW,EAAE,+DAA+D;KAC7E,CAAC;IACD,IAAA,qBAAW,EAAC;QACX,MAAM,EAAE,GAAG;QACX,WAAW,EAAE,oCAAoC;QACjD,IAAI,EAAE,6BAAc;KACrB,CAAC;IACD,IAAA,qBAAW,EAAC;QACX,MAAM,EAAE,GAAG;QACX,WAAW,EAAE,yCAAyC;QACtD,IAAI,EAAE,4BAAa;KACpB,CAAC;IACD,IAAA,qBAAW,EAAC;QACX,MAAM,EAAE,GAAG;QACX,WAAW,EAAE,6BAA6B;QAC1C,IAAI,EAAE,4BAAa;KACpB,CAAC;IACD,IAAA,qBAAW,EAAC;QACX,MAAM,EAAE,GAAG;QACX,WAAW,EAAE,yDAAyD;QACtE,IAAI,EAAE,4BAAa;KACpB,CAAC;IAEC,WAAA,IAAA,YAAG,GAAE,CAAA;IACL,WAAA,IAAA,YAAG,GAAE,CAAA;IACL,WAAA,IAAA,aAAI,GAAE,CAAA;;qDAAM,mBAAY;;wDAuB1B;2BA1IU,gBAAgB;IAJ5B,IAAA,iBAAO,EAAC,QAAQ,CAAC;IACjB,IAAA,uBAAa,GAAE;IACf,IAAA,mBAAU,EAAC,gBAAgB,CAAC;IAC5B,IAAA,kBAAS,EAAC,6BAAc,CAAC;IAIrB,WAAA,IAAA,eAAM,EAAC,iBAAiB,CAAC,CAAA;qCADM,6BAAa;GAFpC,gBAAgB,CA2I5B","sourcesContent":["import { Body, Controller, Get, Inject, Post, Query, Req, Res, UseGuards } from '@nestjs/common';\nimport { ApiBearerAuth, ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';\nimport { Request, Response } from 'express';\nimport { RestUtilities } from '../../Utilities';\nimport { AccessiOptions } from '../AccessiModule';\nimport { ActionResponse, ErrorResponse } from '../Dtos/BaseResponse';\nimport { FiltriUtente, GetFiltriUtenteRequest, GetFiltriUtenteResponse } from '../Dtos';\nimport { GetFiltriResponse } from '../Dtos/TipoFiltro';\nimport { FiltriService } from '../Services/FiltriService/FiltriService';\nimport { JwtSimpleGuard } from '../jwt/jwt.strategy';\nimport {\n ensureSelfOrSuperUser,\n ensureSuperUser,\n getAuthenticatedAccessiUser,\n} from '../security/accessControl';\n\n@ApiTags('Filtri')\n@ApiBearerAuth()\n@Controller('accessi/filtri')\n@UseGuards(JwtSimpleGuard)\nexport class FiltriController {\n constructor(\n private readonly filtriService: FiltriService,\n @Inject('ACCESSI_OPTIONS') private readonly options: AccessiOptions,\n ) {}\n\n @Get('tipi')\n @ApiOperation({\n operationId: 'getTipiFiltro',\n summary: 'Recupera la lista dei tipi di filtri',\n description: 'Ritorna tutti i tipi di filtri disponibili nel sistema',\n })\n @ApiResponse({\n status: 200,\n description: 'Lista dei tipi di filtri recuperata con successo',\n type: GetFiltriResponse,\n })\n @ApiResponse({\n status: 500,\n description: 'Errore interno durante il recupero dei tipi di filtri',\n type: ErrorResponse,\n })\n async getTipoFiltri(@Res() res: Response) {\n try {\n const response = await this.filtriService.getTipoFiltri();\n return RestUtilities.sendBaseResponse(res, response);\n } catch (error) {\n return RestUtilities.sendErrorMessage(res, error, FiltriController.name);\n }\n }\n\n @Get('utente')\n @ApiOperation({\n operationId: 'getFiltriUtente',\n summary: 'Recupera i filtri di un utente',\n description: 'Ritorna tutti i filtri associati ad un utente specifico',\n })\n @ApiResponse({\n status: 200,\n description: \"Lista dei filtri dell'utente recuperata con successo\",\n type: GetFiltriUtenteResponse,\n })\n @ApiResponse({\n status: 400,\n description: 'Errore nella richiesta.',\n type: ErrorResponse,\n })\n @ApiResponse({\n status: 403,\n description: 'Operazione non autorizzata.',\n type: ErrorResponse,\n })\n @ApiResponse({\n status: 500,\n description: 'Errore interno del server.',\n type: ErrorResponse,\n })\n async getFiltriUtente(\n @Req() request: Request,\n @Res() res: Response,\n @Query() req: GetFiltriUtenteRequest,\n ) {\n try {\n const authenticatedUser = getAuthenticatedAccessiUser(request);\n const targetUserCode = req?.codUte;\n\n if (targetUserCode === undefined) {\n ensureSuperUser(\n authenticatedUser,\n 'Solo gli amministratori possono consultare i filtri di tutti gli utenti.',\n );\n } else {\n ensureSelfOrSuperUser(\n authenticatedUser,\n Number(targetUserCode),\n 'Puoi consultare solo i tuoi filtri.',\n );\n }\n\n const response = await this.filtriService.getFiltriUser(targetUserCode);\n return RestUtilities.sendBaseResponse(res, response);\n } catch (error) {\n return RestUtilities.sendErrorMessage(res, error, FiltriController.name);\n }\n }\n\n @Post('utente')\n @ApiOperation({\n operationId: 'saveFiltriUtente',\n summary: 'Inserisce o aggiorna i filtri di un utente',\n description: 'Permette di salvare i filtri associati ad un utente specifico',\n })\n @ApiResponse({\n status: 200,\n description: 'Filtri utente salvati con successo',\n type: ActionResponse,\n })\n @ApiResponse({\n status: 400,\n description: 'Errore di validazione nei dati inviati.',\n type: ErrorResponse,\n })\n @ApiResponse({\n status: 403,\n description: 'Operazione non autorizzata.',\n type: ErrorResponse,\n })\n @ApiResponse({\n status: 500,\n description: 'Errore interno durante il salvataggio dei filtri utente',\n type: ErrorResponse,\n })\n async saveFiltriUtente(\n @Req() request: Request,\n @Res() res: Response,\n @Body() req: FiltriUtente,\n ) {\n try {\n const authenticatedUser = getAuthenticatedAccessiUser(request);\n const targetUserCode = req?.codUte ?? authenticatedUser.codiceUtente;\n\n ensureSelfOrSuperUser(\n authenticatedUser,\n Number(targetUserCode),\n 'Puoi modificare solo i tuoi filtri.',\n );\n\n await this.filtriService.upsertFiltriUtente(targetUserCode, {\n ...req,\n codUte: targetUserCode,\n });\n return RestUtilities.sendOKMessage(\n res,\n `Aggiornamento filtri per l'utente ${targetUserCode} effettuato correttamente`,\n );\n } catch (error) {\n return RestUtilities.sendErrorMessage(res, error, FiltriController.name);\n }\n }\n}\n"]}
|
|
@@ -26,13 +26,14 @@ exports.PermissionController = 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 AssignPermissionsToUserRequest_1 = require("../Dtos/AssignPermissionsToUserRequest");
|
|
30
31
|
const AssignRolesToUserRequest_1 = require("../Dtos/AssignRolesToUserRequest");
|
|
31
32
|
const GetGroupsWithMenusResponse_1 = require("../Dtos/GetGroupsWithMenusResponse");
|
|
32
33
|
const GetMenusResponse_1 = require("../Dtos/GetMenusResponse");
|
|
33
34
|
const GetRolesResponse_1 = require("../Dtos/GetRolesResponse");
|
|
34
35
|
const Role_1 = require("../Dtos/Role");
|
|
35
|
-
const
|
|
36
|
+
const UserGrantsResponse_1 = require("../Dtos/UserGrantsResponse");
|
|
36
37
|
const PermissionService_1 = require("../Services/PermissionService/PermissionService");
|
|
37
38
|
const jwt_strategy_1 = require("../jwt/jwt.strategy");
|
|
38
39
|
const accessControl_1 = require("../security/accessControl");
|
|
@@ -182,11 +183,12 @@ __decorate([
|
|
|
182
183
|
description: 'Recupera tutti i ruoli presenti nel sistema con le relative voci di menu.',
|
|
183
184
|
}),
|
|
184
185
|
(0, swagger_1.ApiOkResponse)({ description: 'Elenco dei ruoli con i rispettivi menu', type: GetRolesResponse_1.GetRolesResponse }),
|
|
185
|
-
(0, swagger_1.ApiInternalServerErrorResponse)({ description: 'Errore interno del server' }),
|
|
186
|
-
(0, swagger_1.ApiResponse)({ status: common_1.HttpStatus.OK, description: 'Lista dei ruoli restituita con successo.' }),
|
|
186
|
+
(0, swagger_1.ApiInternalServerErrorResponse)({ description: 'Errore interno del server', type: BaseResponse_1.ErrorResponse }),
|
|
187
|
+
(0, swagger_1.ApiResponse)({ status: common_1.HttpStatus.OK, description: 'Lista dei ruoli restituita con successo.', type: GetRolesResponse_1.GetRolesResponse }),
|
|
187
188
|
(0, swagger_1.ApiResponse)({
|
|
188
189
|
status: common_1.HttpStatus.INTERNAL_SERVER_ERROR,
|
|
189
190
|
description: 'Errore interno del server durante il recupero dei ruoli.',
|
|
191
|
+
type: BaseResponse_1.ErrorResponse,
|
|
190
192
|
}),
|
|
191
193
|
(0, common_1.Get)('roles'),
|
|
192
194
|
__param(0, (0, common_1.Res)()),
|
|
@@ -207,9 +209,9 @@ __decorate([
|
|
|
207
209
|
description: 'Dati aggiornati del ruolo',
|
|
208
210
|
type: Role_1.Role,
|
|
209
211
|
}),
|
|
210
|
-
(0, swagger_1.ApiResponse)({ status: 200, description: 'Il ruolo e stato aggiornato con successo' }),
|
|
211
|
-
(0, swagger_1.ApiResponse)({ status: 400, description: 'Errore di validazione nei dati inviati' }),
|
|
212
|
-
(0, swagger_1.ApiResponse)({ status: 500, description: 'Errore interno del server' }),
|
|
212
|
+
(0, swagger_1.ApiResponse)({ status: 200, description: 'Il ruolo e stato aggiornato con successo', type: BaseResponse_1.ActionResponse }),
|
|
213
|
+
(0, swagger_1.ApiResponse)({ status: 400, description: 'Errore di validazione nei dati inviati', type: BaseResponse_1.ErrorResponse }),
|
|
214
|
+
(0, swagger_1.ApiResponse)({ status: 500, description: 'Errore interno del server', type: BaseResponse_1.ErrorResponse }),
|
|
213
215
|
(0, common_1.Put)('update-role/:codiceRuolo'),
|
|
214
216
|
__param(0, (0, common_1.Req)()),
|
|
215
217
|
__param(1, (0, common_1.Param)('codiceRuolo', common_1.ParseIntPipe)),
|
|
@@ -221,9 +223,9 @@ __decorate([
|
|
|
221
223
|
], PermissionController.prototype, "updateRole", null);
|
|
222
224
|
__decorate([
|
|
223
225
|
(0, swagger_1.ApiOperation)({ summary: 'Crea un nuovo ruolo', operationId: 'createRole' }),
|
|
224
|
-
(0, swagger_1.ApiResponse)({ status: 201, description: 'Il ruolo e stato creato con successo' }),
|
|
225
|
-
(0, swagger_1.ApiResponse)({ status: 400, description: 'Errore di validazione nei dati inviati' }),
|
|
226
|
-
(0, swagger_1.ApiResponse)({ status: 500, description: 'Errore interno del server' }),
|
|
226
|
+
(0, swagger_1.ApiResponse)({ status: 201, description: 'Il ruolo e stato creato con successo', type: BaseResponse_1.ActionResponse }),
|
|
227
|
+
(0, swagger_1.ApiResponse)({ status: 400, description: 'Errore di validazione nei dati inviati', type: BaseResponse_1.ErrorResponse }),
|
|
228
|
+
(0, swagger_1.ApiResponse)({ status: 500, description: 'Errore interno del server', type: BaseResponse_1.ErrorResponse }),
|
|
227
229
|
(0, swagger_1.ApiBody)({
|
|
228
230
|
description: 'Dati del nuovo ruolo',
|
|
229
231
|
required: true,
|
|
@@ -249,9 +251,9 @@ __decorate([
|
|
|
249
251
|
type: AssignRolesToUserRequest_1.AssignRolesToUserRequest,
|
|
250
252
|
description: "Lista dei ruoli da assegnare all'utente",
|
|
251
253
|
}),
|
|
252
|
-
(0, swagger_1.ApiResponse)({ status: 200, description: "Ruoli assegnati con successo all'utente" }),
|
|
253
|
-
(0, swagger_1.ApiResponse)({ status: 400, description: 'Errore di validazione nei dati inviati' }),
|
|
254
|
-
(0, swagger_1.ApiResponse)({ status: 500, description: 'Errore interno del server' }),
|
|
254
|
+
(0, swagger_1.ApiResponse)({ status: 200, description: "Ruoli assegnati con successo all'utente", type: BaseResponse_1.ActionResponse }),
|
|
255
|
+
(0, swagger_1.ApiResponse)({ status: 400, description: 'Errore di validazione nei dati inviati', type: BaseResponse_1.ErrorResponse }),
|
|
256
|
+
(0, swagger_1.ApiResponse)({ status: 500, description: 'Errore interno del server', type: BaseResponse_1.ErrorResponse }),
|
|
255
257
|
(0, common_1.Post)('assign-roles/:codiceUtente'),
|
|
256
258
|
__param(0, (0, common_1.Req)()),
|
|
257
259
|
__param(1, (0, common_1.Res)()),
|
|
@@ -276,9 +278,9 @@ __decorate([
|
|
|
276
278
|
type: AssignPermissionsToUserRequest_1.AssignPermissionsToUserRequest,
|
|
277
279
|
description: "Lista delle abilitazioni da assegnare all'utente",
|
|
278
280
|
}),
|
|
279
|
-
(0, swagger_1.ApiResponse)({ status: 200, description: "Abilitazioni assegnate con successo all'utente" }),
|
|
280
|
-
(0, swagger_1.ApiResponse)({ status: 400, description: 'Errore di validazione nei dati inviati' }),
|
|
281
|
-
(0, swagger_1.ApiResponse)({ status: 500, description: 'Errore interno del server' }),
|
|
281
|
+
(0, swagger_1.ApiResponse)({ status: 200, description: "Abilitazioni assegnate con successo all'utente", type: BaseResponse_1.ActionResponse }),
|
|
282
|
+
(0, swagger_1.ApiResponse)({ status: 400, description: 'Errore di validazione nei dati inviati', type: BaseResponse_1.ErrorResponse }),
|
|
283
|
+
(0, swagger_1.ApiResponse)({ status: 500, description: 'Errore interno del server', type: BaseResponse_1.ErrorResponse }),
|
|
282
284
|
(0, common_1.Post)('assign-permissions/:codiceUtente'),
|
|
283
285
|
__param(0, (0, common_1.Req)()),
|
|
284
286
|
__param(1, (0, common_1.Res)()),
|
|
@@ -297,9 +299,9 @@ __decorate([
|
|
|
297
299
|
example: 382,
|
|
298
300
|
type: Number,
|
|
299
301
|
}),
|
|
300
|
-
(0, swagger_1.ApiResponse)({ status: 200, description: 'Ruolo eliminato con successo' }),
|
|
301
|
-
(0, swagger_1.ApiResponse)({ status: 400, description: 'Errore nei parametri della richiesta' }),
|
|
302
|
-
(0, swagger_1.ApiResponse)({ status: 500, description: 'Errore interno del server' }),
|
|
302
|
+
(0, swagger_1.ApiResponse)({ status: 200, description: 'Ruolo eliminato con successo', type: BaseResponse_1.ActionResponse }),
|
|
303
|
+
(0, swagger_1.ApiResponse)({ status: 400, description: 'Errore nei parametri della richiesta', type: BaseResponse_1.ErrorResponse }),
|
|
304
|
+
(0, swagger_1.ApiResponse)({ status: 500, description: 'Errore interno del server', type: BaseResponse_1.ErrorResponse }),
|
|
303
305
|
(0, common_1.Delete)('delete-role/:codiceRuolo'),
|
|
304
306
|
__param(0, (0, common_1.Req)()),
|
|
305
307
|
__param(1, (0, common_1.Param)('codiceRuolo', common_1.ParseIntPipe)),
|
|
@@ -311,8 +313,8 @@ __decorate([
|
|
|
311
313
|
__decorate([
|
|
312
314
|
(0, swagger_1.ApiOperation)({ summary: 'Recupera tutti i menu disponibili', operationId: 'getMenus' }),
|
|
313
315
|
(0, swagger_1.ApiOkResponse)({ description: 'Elenco menu', type: GetMenusResponse_1.GetMenusResponse }),
|
|
314
|
-
(0, swagger_1.ApiResponse)({ status: 200, description: 'Lista dei menu recuperata con successo' }),
|
|
315
|
-
(0, swagger_1.ApiResponse)({ status: 500, description: 'Errore interno del server' }),
|
|
316
|
+
(0, swagger_1.ApiResponse)({ status: 200, description: 'Lista dei menu recuperata con successo', type: GetMenusResponse_1.GetMenusResponse }),
|
|
317
|
+
(0, swagger_1.ApiResponse)({ status: 500, description: 'Errore interno del server', type: BaseResponse_1.ErrorResponse }),
|
|
316
318
|
(0, common_1.Get)('menus'),
|
|
317
319
|
__param(0, (0, common_1.Res)()),
|
|
318
320
|
__metadata("design:type", Function),
|
|
@@ -328,8 +330,8 @@ __decorate([
|
|
|
328
330
|
description: 'Elenco gruppi con relativi menu',
|
|
329
331
|
type: GetGroupsWithMenusResponse_1.GetGroupsWithMenusResponse,
|
|
330
332
|
}),
|
|
331
|
-
(0, swagger_1.ApiResponse)({ status: 200, description: 'Lista dei menu recuperata con successo' }),
|
|
332
|
-
(0, swagger_1.ApiResponse)({ status: 500, description: 'Errore interno del server' }),
|
|
333
|
+
(0, swagger_1.ApiResponse)({ status: 200, description: 'Lista dei menu recuperata con successo', type: GetGroupsWithMenusResponse_1.GetGroupsWithMenusResponse }),
|
|
334
|
+
(0, swagger_1.ApiResponse)({ status: 500, description: 'Errore interno del server', type: BaseResponse_1.ErrorResponse }),
|
|
333
335
|
(0, swagger_1.ApiQuery)({
|
|
334
336
|
name: 'includeDisabled',
|
|
335
337
|
required: false,
|
|
@@ -348,9 +350,9 @@ __decorate([
|
|
|
348
350
|
summary: 'Recupera i ruoli e i menu di un utente',
|
|
349
351
|
operationId: 'getUserRolesAndGrants',
|
|
350
352
|
}),
|
|
351
|
-
(0, swagger_1.ApiOkResponse)({ description: 'Elenco
|
|
352
|
-
(0, swagger_1.ApiResponse)({ status: 200, description: '
|
|
353
|
-
(0, swagger_1.ApiResponse)({ status: 500, description: 'Errore interno del server' }),
|
|
353
|
+
(0, swagger_1.ApiOkResponse)({ description: 'Elenco grant utente', type: UserGrantsResponse_1.UserGrantsResponse }),
|
|
354
|
+
(0, swagger_1.ApiResponse)({ status: 200, description: 'Grant utente recuperati con successo', type: UserGrantsResponse_1.UserGrantsResponse }),
|
|
355
|
+
(0, swagger_1.ApiResponse)({ status: 500, description: 'Errore interno del server', type: BaseResponse_1.ErrorResponse }),
|
|
354
356
|
(0, common_1.Get)('grants/:codiceUtente'),
|
|
355
357
|
__param(0, (0, common_1.Req)()),
|
|
356
358
|
__param(1, (0, common_1.Param)('codiceUtente', common_1.ParseIntPipe)),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PermissionController.js","sourceRoot":"","sources":["../../../src/accessi-module/Controllers/PermissionController.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAewB;AACxB,6CAUyB;AAEzB,+CAAgD;AAChD,2FAAwF;AACxF,+EAA4E;AAC5E,mFAAgF;AAChF,+DAA4D;AAC5D,+DAA4D;AAC5D,uCAAoC;AACpC,yDAAsD;AACtD,uFAAoF;AACpF,sDAAqD;AACrD,6DAImC;AAM5B,IAAM,oBAAoB,4BAA1B,MAAM,oBAAoB;IAC/B,YAA6B,iBAAoC;QAApC,sBAAiB,GAAjB,iBAAiB,CAAmB;IAAG,CAAC;IAE7D,mBAAmB,CAAC,GAAa,EAAE,KAAc;QACvD,MAAM,MAAM,GACV,KAAK,YAAY,sBAAa,CAAC,CAAC,CAAC,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,mBAAU,CAAC,qBAAqB,CAAC;QACxF,OAAO,yBAAa,CAAC,gBAAgB,CAAC,GAAG,EAAE,KAAK,EAAE,sBAAoB,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACvF,CAAC;IAeK,QAAQ,CAAQ,GAAa;;YACjC,I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AA,YAAG,GAAE,CAAA;;;;iEAcP;+BAzSU,oBAAoB;IAJhC,IAAA,iBAAO,EAAC,YAAY,CAAC;IACrB,IAAA,uBAAa,GAAE;IACf,IAAA,mBAAU,EAAC,oBAAoB,CAAC;IAChC,IAAA,kBAAS,EAAC,6BAAc,CAAC;qCAEwB,qCAAiB;GADtD,oBAAoB,CA0ShC","sourcesContent":["import {\n Body,\n Controller,\n Delete,\n Get,\n HttpException,\n HttpStatus,\n Param,\n ParseIntPipe,\n Post,\n Put,\n Query,\n Req,\n Res,\n UseGuards,\n} from '@nestjs/common';\nimport {\n ApiBearerAuth,\n ApiBody,\n ApiInternalServerErrorResponse,\n ApiOkResponse,\n ApiOperation,\n ApiParam,\n ApiQuery,\n ApiResponse,\n ApiTags,\n} from '@nestjs/swagger';\nimport { Request, Response } from 'express';\nimport { RestUtilities } from '../../Utilities';\nimport { AssignPermissionsToUserRequest } from '../Dtos/AssignPermissionsToUserRequest';\nimport { AssignRolesToUserRequest } from '../Dtos/AssignRolesToUserRequest';\nimport { GetGroupsWithMenusResponse } from '../Dtos/GetGroupsWithMenusResponse';\nimport { GetMenusResponse } from '../Dtos/GetMenusResponse';\nimport { GetRolesResponse } from '../Dtos/GetRolesResponse';\nimport { Role } from '../Dtos/Role';\nimport { UserGrantsDto } from '../Dtos/UserGrantsDto';\nimport { PermissionService } from '../Services/PermissionService/PermissionService';\nimport { JwtSimpleGuard } from '../jwt/jwt.strategy';\nimport {\n ensureSelfOrSuperUser,\n ensureSuperUser,\n getAuthenticatedAccessiUser,\n} from '../security/accessControl';\n\n@ApiTags('Permission')\n@ApiBearerAuth()\n@Controller('accessi/permission')\n@UseGuards(JwtSimpleGuard)\nexport class PermissionController {\n constructor(private readonly permissionService: PermissionService) {}\n\n private sendControllerError(res: Response, error: unknown) {\n const status =\n error instanceof HttpException ? error.getStatus() : HttpStatus.INTERNAL_SERVER_ERROR;\n return RestUtilities.sendErrorMessage(res, error, PermissionController.name, status);\n }\n\n @ApiOperation({\n summary: 'Ritorna i ruoli disponibili con i relativi menu',\n operationId: 'getRoles',\n description: 'Recupera tutti i ruoli presenti nel sistema con le relative voci di menu.',\n })\n @ApiOkResponse({ description: 'Elenco dei ruoli con i rispettivi menu', type: GetRolesResponse })\n @ApiInternalServerErrorResponse({ description: 'Errore interno del server' })\n @ApiResponse({ status: HttpStatus.OK, description: 'Lista dei ruoli restituita con successo.' })\n @ApiResponse({\n status: HttpStatus.INTERNAL_SERVER_ERROR,\n description: 'Errore interno del server durante il recupero dei ruoli.',\n })\n @Get('roles')\n async getRoles(@Res() res: Response): Promise<void> {\n try {\n const roles = await this.permissionService.getRolesWithMenus();\n RestUtilities.sendBaseResponse(res, roles);\n } catch (error) {\n this.sendControllerError(res, error);\n throw error;\n }\n }\n\n @ApiOperation({ summary: 'Aggiorna un ruolo esistente', operationId: 'updateRole' })\n @ApiParam({\n name: 'codiceRuolo',\n description: 'Codice identificativo del ruolo da aggiornare',\n required: true,\n example: 101,\n type: Number,\n })\n @ApiBody({\n description: 'Dati aggiornati del ruolo',\n type: Role,\n })\n @ApiResponse({ status: 200, description: 'Il ruolo e stato aggiornato con successo' })\n @ApiResponse({ status: 400, description: 'Errore di validazione nei dati inviati' })\n @ApiResponse({ status: 500, description: 'Errore interno del server' })\n @Put('update-role/:codiceRuolo')\n async updateRole(\n @Req() request: Request,\n @Param('codiceRuolo', ParseIntPipe) codiceRuolo: number,\n @Body() role: Role,\n @Res() res: Response,\n ) {\n try {\n ensureSuperUser(\n getAuthenticatedAccessiUser(request),\n 'Solo gli amministratori possono modificare i ruoli.',\n );\n\n if (Number.isNaN(codiceRuolo)) throw new Error('Il codice del ruolo e obbligatorio.');\n if (!role.descrizioneRuolo) throw new Error('La descrizione del ruolo non puo essere vuota.');\n if (!role.menu || role.menu.length === 0) {\n throw new Error('Il ruolo deve avere almeno un menu.');\n }\n\n await this.permissionService.updateOrInsertRole(role, codiceRuolo);\n return RestUtilities.sendOKMessage(\n res,\n `Il ruolo ${codiceRuolo} e' stato aggiornato con successo.`,\n );\n } catch (error) {\n return this.sendControllerError(res, error);\n }\n }\n\n @ApiOperation({ summary: 'Crea un nuovo ruolo', operationId: 'createRole' })\n @ApiResponse({ status: 201, description: 'Il ruolo e stato creato con successo' })\n @ApiResponse({ status: 400, description: 'Errore di validazione nei dati inviati' })\n @ApiResponse({ status: 500, description: 'Errore interno del server' })\n @ApiBody({\n description: 'Dati del nuovo ruolo',\n required: true,\n type: Role,\n })\n @Post('create-role')\n async createRole(@Req() request: Request, @Res() res: Response, @Body() role: Role) {\n try {\n ensureSuperUser(\n getAuthenticatedAccessiUser(request),\n 'Solo gli amministratori possono creare ruoli.',\n );\n\n if (!role) throw new Error('Il ruolo non puo essere vuoto.');\n if (!role.descrizioneRuolo) throw new Error('La descrizione del ruolo non puo essere vuota.');\n if (!role.menu || role.menu.length === 0) {\n throw new Error('Il ruolo deve avere almeno un menu.');\n }\n\n await this.permissionService.updateOrInsertRole(role);\n return RestUtilities.sendOKMessage(res, 'Il ruolo e stato creato con successo.');\n } catch (error) {\n return this.sendControllerError(res, error);\n }\n }\n\n @ApiOperation({ summary: 'Assegna piu ruoli a un utente', operationId: 'assignRolesToUser' })\n @ApiParam({\n name: 'codiceUtente',\n description: \"Codice identificativo dell'utente a cui assegnare i ruoli\",\n required: true,\n example: 22,\n })\n @ApiBody({\n type: AssignRolesToUserRequest,\n description: \"Lista dei ruoli da assegnare all'utente\",\n })\n @ApiResponse({ status: 200, description: \"Ruoli assegnati con successo all'utente\" })\n @ApiResponse({ status: 400, description: 'Errore di validazione nei dati inviati' })\n @ApiResponse({ status: 500, description: 'Errore interno del server' })\n @Post('assign-roles/:codiceUtente')\n async assignRolesToUser(\n @Req() request: Request,\n @Res() res: Response,\n @Param('codiceUtente', ParseIntPipe) codiceUtente: number,\n @Body() assignRolesRequest: AssignRolesToUserRequest,\n ) {\n try {\n ensureSuperUser(\n getAuthenticatedAccessiUser(request),\n 'Solo gli amministratori possono assegnare ruoli agli utenti.',\n );\n\n if (!assignRolesRequest.roles || assignRolesRequest.roles.length === 0) {\n throw new Error('E necessario fornire almeno un ruolo.');\n }\n\n await this.permissionService.assignRolesToUser(codiceUtente, assignRolesRequest.roles);\n return RestUtilities.sendOKMessage(\n res,\n `I ruoli ${assignRolesRequest.roles.join(', ')} sono stati assegnati all'utente ${codiceUtente}.`,\n );\n } catch (error) {\n return this.sendControllerError(res, error);\n }\n }\n\n @ApiOperation({\n summary: 'Assegna abilitazioni dirette a un utente',\n operationId: 'assignPermissionsToUser',\n })\n @ApiParam({\n name: 'codiceUtente',\n description: \"Codice identificativo dell'utente a cui assegnare le abilitazioni\",\n required: true,\n example: 22,\n })\n @ApiBody({\n type: AssignPermissionsToUserRequest,\n description: \"Lista delle abilitazioni da assegnare all'utente\",\n })\n @ApiResponse({ status: 200, description: \"Abilitazioni assegnate con successo all'utente\" })\n @ApiResponse({ status: 400, description: 'Errore di validazione nei dati inviati' })\n @ApiResponse({ status: 500, description: 'Errore interno del server' })\n @Post('assign-permissions/:codiceUtente')\n async assignPermissionsToUser(\n @Req() request: Request,\n @Res() res: Response,\n @Param('codiceUtente', ParseIntPipe) codiceUtente: number,\n @Body() assignPermissionsRequest: AssignPermissionsToUserRequest,\n ) {\n try {\n ensureSuperUser(\n getAuthenticatedAccessiUser(request),\n 'Solo gli amministratori possono assegnare permessi agli utenti.',\n );\n\n if (!assignPermissionsRequest.permissions || assignPermissionsRequest.permissions.length === 0) {\n throw new Error('E necessario fornire almeno una abilitazione.');\n }\n\n await this.permissionService.assignPermissionsToUser(\n codiceUtente,\n assignPermissionsRequest.permissions,\n );\n return RestUtilities.sendOKMessage(\n res,\n `Le abilitazioni sono state assegnate all'utente ${codiceUtente}.`,\n );\n } catch (error) {\n return this.sendControllerError(res, error);\n }\n }\n\n @ApiOperation({ summary: 'Elimina un ruolo esistente', operationId: 'deleteRole' })\n @ApiParam({\n name: 'codiceRuolo',\n description: 'Codice identificativo del ruolo da eliminare',\n required: true,\n example: 382,\n type: Number,\n })\n @ApiResponse({ status: 200, description: 'Ruolo eliminato con successo' })\n @ApiResponse({ status: 400, description: 'Errore nei parametri della richiesta' })\n @ApiResponse({ status: 500, description: 'Errore interno del server' })\n @Delete('delete-role/:codiceRuolo')\n async deleteRole(\n @Req() request: Request,\n @Param('codiceRuolo', ParseIntPipe) codiceRuolo: number,\n @Res() res: Response,\n ) {\n try {\n ensureSuperUser(\n getAuthenticatedAccessiUser(request),\n 'Solo gli amministratori possono eliminare ruoli.',\n );\n\n await this.permissionService.deleteRole(codiceRuolo);\n return RestUtilities.sendOKMessage(\n res,\n `Il ruolo ${codiceRuolo} e' stato eliminato con successo.`,\n );\n } catch (error) {\n return this.sendControllerError(res, error);\n }\n }\n\n @ApiOperation({ summary: 'Recupera tutti i menu disponibili', operationId: 'getMenus' })\n @ApiOkResponse({ description: 'Elenco menu', type: GetMenusResponse })\n @ApiResponse({ status: 200, description: 'Lista dei menu recuperata con successo' })\n @ApiResponse({ status: 500, description: 'Errore interno del server' })\n @Get('menus')\n async getMenus(@Res() res: Response) {\n try {\n const menus = await this.permissionService.getMenus();\n return RestUtilities.sendBaseResponse(res, menus);\n } catch (error) {\n return this.sendControllerError(res, error);\n }\n }\n\n @ApiOperation({\n summary: 'Recupera tutti i gruppi disponibili con i relativi menu',\n operationId: 'getGroupsWithMenus',\n })\n @ApiOkResponse({\n description: 'Elenco gruppi con relativi menu',\n type: GetGroupsWithMenusResponse,\n })\n @ApiResponse({ status: 200, description: 'Lista dei menu recuperata con successo' })\n @ApiResponse({ status: 500, description: 'Errore interno del server' })\n @ApiQuery({\n name: 'includeDisabled',\n required: false,\n type: Boolean,\n description: 'Quando true ritorna anche i menu e gruppi disabilitati.',\n })\n @Get('groups-with-menus')\n async getGroupsWithMenus(@Query('includeDisabled') includeDisabled: string, @Res() res: Response) {\n try {\n const includeDisabledFlag =\n typeof includeDisabled === 'string'\n ? ['true', '1', 'yes'].includes(includeDisabled.toLowerCase())\n : false;\n\n const menus = await this.permissionService.getGroupsWithMenus(includeDisabledFlag);\n return RestUtilities.sendBaseResponse(res, menus);\n } catch (error) {\n return this.sendControllerError(res, error);\n }\n }\n\n @ApiOperation({\n summary: 'Recupera i ruoli e i menu di un utente',\n operationId: 'getUserRolesAndGrants',\n })\n @ApiOkResponse({ description: 'Elenco menu', type: UserGrantsDto })\n @ApiResponse({ status: 200, description: 'Lista dei menu recuperata con successo' })\n @ApiResponse({ status: 500, description: 'Errore interno del server' })\n @Get('grants/:codiceUtente')\n async getUserRolesAndGrants(\n @Req() request: Request,\n @Param('codiceUtente', ParseIntPipe) codiceUtente: number,\n @Res() res: Response,\n ) {\n try {\n ensureSelfOrSuperUser(\n getAuthenticatedAccessiUser(request),\n codiceUtente,\n 'Puoi consultare solo i tuoi grant, salvo privilegi amministrativi.',\n );\n\n const menus = await this.permissionService.getUserRolesAndGrants(codiceUtente);\n return RestUtilities.sendBaseResponse(res, menus);\n } catch (error) {\n return this.sendControllerError(res, error);\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"PermissionController.js","sourceRoot":"","sources":["../../../src/accessi-module/Controllers/PermissionController.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAewB;AACxB,6CAUyB;AAEzB,+CAAgD;AAChD,uDAAqE;AACrE,2FAAwF;AACxF,+EAA4E;AAC5E,mFAAgF;AAChF,+DAA4D;AAC5D,+DAA4D;AAC5D,uCAAoC;AAEpC,mEAAgE;AAChE,uFAAoF;AACpF,sDAAqD;AACrD,6DAImC;AAM5B,IAAM,oBAAoB,4BAA1B,MAAM,oBAAoB;IAC/B,YAA6B,iBAAoC;QAApC,sBAAiB,GAAjB,iBAAiB,CAAmB;IAAG,CAAC;IAE7D,mBAAmB,CAAC,GAAa,EAAE,KAAc;QACvD,MAAM,MAAM,GACV,KAAK,YAAY,sBAAa,CAAC,CAAC,CAAC,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,mBAAU,CAAC,qBAAqB,CAAC;Q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B,QAAQ,EAAE,KAAK;QACf,IAAI,EAAE,OAAO;QACb,WAAW,EAAE,yDAAyD;KACvE,CAAC;IACD,IAAA,YAAG,EAAC,mBAAmB,CAAC;IACC,WAAA,IAAA,cAAK,EAAC,iBAAiB,CAAC,CAAA;IAA2B,WAAA,IAAA,YAAG,GAAE,CAAA;;;;8DAYjF;AAUK;IARL,IAAA,sBAAY,EAAC;QACZ,OAAO,EAAE,wCAAwC;QACjD,WAAW,EAAE,uBAAuB;KACrC,CAAC;IACD,IAAA,uBAAa,EAAC,EAAE,WAAW,EAAE,qBAAqB,EAAE,IAAI,EAAE,uCAAkB,EAAE,CAAC;IAC/E,IAAA,qBAAW,EAAC,EAAE,MAAM,EAAE,GAAG,EAAE,WAAW,EAAE,sCAAsC,EAAE,IAAI,EAAE,uCAAkB,EAAE,CAAC;IAC3G,IAAA,qBAAW,EAAC,EAAE,MAAM,EAAE,GAAG,EAAE,WAAW,EAAE,2BAA2B,EAAE,IAAI,EAAE,4BAAa,EAAE,CAAC;IAC3F,IAAA,YAAG,EAAC,sBAAsB,CAAC;IAEzB,WAAA,IAAA,YAAG,GAAE,CAAA;IACL,WAAA,IAAA,cAAK,EAAC,cAAc,EAAE,qBAAY,CAAC,CAAA;IACnC,WAAA,IAAA,YAAG,GAAE,CAAA;;;;iEAcP;+BA1SU,oBAAoB;IAJhC,IAAA,iBAAO,EAAC,YAAY,CAAC;IACrB,IAAA,uBAAa,GAAE;IACf,IAAA,mBAAU,EAAC,oBAAoB,CAAC;IAChC,IAAA,kBAAS,EAAC,6BAAc,CAAC;qCAEwB,qCAAiB;GADtD,oBAAoB,CA2ShC","sourcesContent":["import {\n Body,\n Controller,\n Delete,\n Get,\n HttpException,\n HttpStatus,\n Param,\n ParseIntPipe,\n Post,\n Put,\n Query,\n Req,\n Res,\n UseGuards,\n} from '@nestjs/common';\nimport {\n ApiBearerAuth,\n ApiBody,\n ApiInternalServerErrorResponse,\n ApiOkResponse,\n ApiOperation,\n ApiParam,\n ApiQuery,\n ApiResponse,\n ApiTags,\n} from '@nestjs/swagger';\nimport { Request, Response } from 'express';\nimport { RestUtilities } from '../../Utilities';\nimport { ActionResponse, ErrorResponse } from '../Dtos/BaseResponse';\nimport { AssignPermissionsToUserRequest } from '../Dtos/AssignPermissionsToUserRequest';\nimport { AssignRolesToUserRequest } from '../Dtos/AssignRolesToUserRequest';\nimport { GetGroupsWithMenusResponse } from '../Dtos/GetGroupsWithMenusResponse';\nimport { GetMenusResponse } from '../Dtos/GetMenusResponse';\nimport { GetRolesResponse } from '../Dtos/GetRolesResponse';\nimport { Role } from '../Dtos/Role';\nimport { UserGrantsDto } from '../Dtos/UserGrantsDto';\nimport { UserGrantsResponse } from '../Dtos/UserGrantsResponse';\nimport { PermissionService } from '../Services/PermissionService/PermissionService';\nimport { JwtSimpleGuard } from '../jwt/jwt.strategy';\nimport {\n ensureSelfOrSuperUser,\n ensureSuperUser,\n getAuthenticatedAccessiUser,\n} from '../security/accessControl';\n\n@ApiTags('Permission')\n@ApiBearerAuth()\n@Controller('accessi/permission')\n@UseGuards(JwtSimpleGuard)\nexport class PermissionController {\n constructor(private readonly permissionService: PermissionService) {}\n\n private sendControllerError(res: Response, error: unknown) {\n const status =\n error instanceof HttpException ? error.getStatus() : HttpStatus.INTERNAL_SERVER_ERROR;\n return RestUtilities.sendErrorMessage(res, error, PermissionController.name, status);\n }\n\n @ApiOperation({\n summary: 'Ritorna i ruoli disponibili con i relativi menu',\n operationId: 'getRoles',\n description: 'Recupera tutti i ruoli presenti nel sistema con le relative voci di menu.',\n })\n @ApiOkResponse({ description: 'Elenco dei ruoli con i rispettivi menu', type: GetRolesResponse })\n @ApiInternalServerErrorResponse({ description: 'Errore interno del server', type: ErrorResponse })\n @ApiResponse({ status: HttpStatus.OK, description: 'Lista dei ruoli restituita con successo.', type: GetRolesResponse })\n @ApiResponse({\n status: HttpStatus.INTERNAL_SERVER_ERROR,\n description: 'Errore interno del server durante il recupero dei ruoli.',\n type: ErrorResponse,\n })\n @Get('roles')\n async getRoles(@Res() res: Response): Promise<void> {\n try {\n const roles = await this.permissionService.getRolesWithMenus();\n RestUtilities.sendBaseResponse(res, roles);\n } catch (error) {\n this.sendControllerError(res, error);\n throw error;\n }\n }\n\n @ApiOperation({ summary: 'Aggiorna un ruolo esistente', operationId: 'updateRole' })\n @ApiParam({\n name: 'codiceRuolo',\n description: 'Codice identificativo del ruolo da aggiornare',\n required: true,\n example: 101,\n type: Number,\n })\n @ApiBody({\n description: 'Dati aggiornati del ruolo',\n type: Role,\n })\n @ApiResponse({ status: 200, description: 'Il ruolo e stato aggiornato con successo', type: ActionResponse })\n @ApiResponse({ status: 400, description: 'Errore di validazione nei dati inviati', type: ErrorResponse })\n @ApiResponse({ status: 500, description: 'Errore interno del server', type: ErrorResponse })\n @Put('update-role/:codiceRuolo')\n async updateRole(\n @Req() request: Request,\n @Param('codiceRuolo', ParseIntPipe) codiceRuolo: number,\n @Body() role: Role,\n @Res() res: Response,\n ) {\n try {\n ensureSuperUser(\n getAuthenticatedAccessiUser(request),\n 'Solo gli amministratori possono modificare i ruoli.',\n );\n\n if (Number.isNaN(codiceRuolo)) throw new Error('Il codice del ruolo e obbligatorio.');\n if (!role.descrizioneRuolo) throw new Error('La descrizione del ruolo non puo essere vuota.');\n if (!role.menu || role.menu.length === 0) {\n throw new Error('Il ruolo deve avere almeno un menu.');\n }\n\n await this.permissionService.updateOrInsertRole(role, codiceRuolo);\n return RestUtilities.sendOKMessage(\n res,\n `Il ruolo ${codiceRuolo} e' stato aggiornato con successo.`,\n );\n } catch (error) {\n return this.sendControllerError(res, error);\n }\n }\n\n @ApiOperation({ summary: 'Crea un nuovo ruolo', operationId: 'createRole' })\n @ApiResponse({ status: 201, description: 'Il ruolo e stato creato con successo', type: ActionResponse })\n @ApiResponse({ status: 400, description: 'Errore di validazione nei dati inviati', type: ErrorResponse })\n @ApiResponse({ status: 500, description: 'Errore interno del server', type: ErrorResponse })\n @ApiBody({\n description: 'Dati del nuovo ruolo',\n required: true,\n type: Role,\n })\n @Post('create-role')\n async createRole(@Req() request: Request, @Res() res: Response, @Body() role: Role) {\n try {\n ensureSuperUser(\n getAuthenticatedAccessiUser(request),\n 'Solo gli amministratori possono creare ruoli.',\n );\n\n if (!role) throw new Error('Il ruolo non puo essere vuoto.');\n if (!role.descrizioneRuolo) throw new Error('La descrizione del ruolo non puo essere vuota.');\n if (!role.menu || role.menu.length === 0) {\n throw new Error('Il ruolo deve avere almeno un menu.');\n }\n\n await this.permissionService.updateOrInsertRole(role);\n return RestUtilities.sendOKMessage(res, 'Il ruolo e stato creato con successo.');\n } catch (error) {\n return this.sendControllerError(res, error);\n }\n }\n\n @ApiOperation({ summary: 'Assegna piu ruoli a un utente', operationId: 'assignRolesToUser' })\n @ApiParam({\n name: 'codiceUtente',\n description: \"Codice identificativo dell'utente a cui assegnare i ruoli\",\n required: true,\n example: 22,\n })\n @ApiBody({\n type: AssignRolesToUserRequest,\n description: \"Lista dei ruoli da assegnare all'utente\",\n })\n @ApiResponse({ status: 200, description: \"Ruoli assegnati con successo all'utente\", type: ActionResponse })\n @ApiResponse({ status: 400, description: 'Errore di validazione nei dati inviati', type: ErrorResponse })\n @ApiResponse({ status: 500, description: 'Errore interno del server', type: ErrorResponse })\n @Post('assign-roles/:codiceUtente')\n async assignRolesToUser(\n @Req() request: Request,\n @Res() res: Response,\n @Param('codiceUtente', ParseIntPipe) codiceUtente: number,\n @Body() assignRolesRequest: AssignRolesToUserRequest,\n ) {\n try {\n ensureSuperUser(\n getAuthenticatedAccessiUser(request),\n 'Solo gli amministratori possono assegnare ruoli agli utenti.',\n );\n\n if (!assignRolesRequest.roles || assignRolesRequest.roles.length === 0) {\n throw new Error('E necessario fornire almeno un ruolo.');\n }\n\n await this.permissionService.assignRolesToUser(codiceUtente, assignRolesRequest.roles);\n return RestUtilities.sendOKMessage(\n res,\n `I ruoli ${assignRolesRequest.roles.join(', ')} sono stati assegnati all'utente ${codiceUtente}.`,\n );\n } catch (error) {\n return this.sendControllerError(res, error);\n }\n }\n\n @ApiOperation({\n summary: 'Assegna abilitazioni dirette a un utente',\n operationId: 'assignPermissionsToUser',\n })\n @ApiParam({\n name: 'codiceUtente',\n description: \"Codice identificativo dell'utente a cui assegnare le abilitazioni\",\n required: true,\n example: 22,\n })\n @ApiBody({\n type: AssignPermissionsToUserRequest,\n description: \"Lista delle abilitazioni da assegnare all'utente\",\n })\n @ApiResponse({ status: 200, description: \"Abilitazioni assegnate con successo all'utente\", type: ActionResponse })\n @ApiResponse({ status: 400, description: 'Errore di validazione nei dati inviati', type: ErrorResponse })\n @ApiResponse({ status: 500, description: 'Errore interno del server', type: ErrorResponse })\n @Post('assign-permissions/:codiceUtente')\n async assignPermissionsToUser(\n @Req() request: Request,\n @Res() res: Response,\n @Param('codiceUtente', ParseIntPipe) codiceUtente: number,\n @Body() assignPermissionsRequest: AssignPermissionsToUserRequest,\n ) {\n try {\n ensureSuperUser(\n getAuthenticatedAccessiUser(request),\n 'Solo gli amministratori possono assegnare permessi agli utenti.',\n );\n\n if (!assignPermissionsRequest.permissions || assignPermissionsRequest.permissions.length === 0) {\n throw new Error('E necessario fornire almeno una abilitazione.');\n }\n\n await this.permissionService.assignPermissionsToUser(\n codiceUtente,\n assignPermissionsRequest.permissions,\n );\n return RestUtilities.sendOKMessage(\n res,\n `Le abilitazioni sono state assegnate all'utente ${codiceUtente}.`,\n );\n } catch (error) {\n return this.sendControllerError(res, error);\n }\n }\n\n @ApiOperation({ summary: 'Elimina un ruolo esistente', operationId: 'deleteRole' })\n @ApiParam({\n name: 'codiceRuolo',\n description: 'Codice identificativo del ruolo da eliminare',\n required: true,\n example: 382,\n type: Number,\n })\n @ApiResponse({ status: 200, description: 'Ruolo eliminato con successo', type: ActionResponse })\n @ApiResponse({ status: 400, description: 'Errore nei parametri della richiesta', type: ErrorResponse })\n @ApiResponse({ status: 500, description: 'Errore interno del server', type: ErrorResponse })\n @Delete('delete-role/:codiceRuolo')\n async deleteRole(\n @Req() request: Request,\n @Param('codiceRuolo', ParseIntPipe) codiceRuolo: number,\n @Res() res: Response,\n ) {\n try {\n ensureSuperUser(\n getAuthenticatedAccessiUser(request),\n 'Solo gli amministratori possono eliminare ruoli.',\n );\n\n await this.permissionService.deleteRole(codiceRuolo);\n return RestUtilities.sendOKMessage(\n res,\n `Il ruolo ${codiceRuolo} e' stato eliminato con successo.`,\n );\n } catch (error) {\n return this.sendControllerError(res, error);\n }\n }\n\n @ApiOperation({ summary: 'Recupera tutti i menu disponibili', operationId: 'getMenus' })\n @ApiOkResponse({ description: 'Elenco menu', type: GetMenusResponse })\n @ApiResponse({ status: 200, description: 'Lista dei menu recuperata con successo', type: GetMenusResponse })\n @ApiResponse({ status: 500, description: 'Errore interno del server', type: ErrorResponse })\n @Get('menus')\n async getMenus(@Res() res: Response) {\n try {\n const menus = await this.permissionService.getMenus();\n return RestUtilities.sendBaseResponse(res, menus);\n } catch (error) {\n return this.sendControllerError(res, error);\n }\n }\n\n @ApiOperation({\n summary: 'Recupera tutti i gruppi disponibili con i relativi menu',\n operationId: 'getGroupsWithMenus',\n })\n @ApiOkResponse({\n description: 'Elenco gruppi con relativi menu',\n type: GetGroupsWithMenusResponse,\n })\n @ApiResponse({ status: 200, description: 'Lista dei menu recuperata con successo', type: GetGroupsWithMenusResponse })\n @ApiResponse({ status: 500, description: 'Errore interno del server', type: ErrorResponse })\n @ApiQuery({\n name: 'includeDisabled',\n required: false,\n type: Boolean,\n description: 'Quando true ritorna anche i menu e gruppi disabilitati.',\n })\n @Get('groups-with-menus')\n async getGroupsWithMenus(@Query('includeDisabled') includeDisabled: string, @Res() res: Response) {\n try {\n const includeDisabledFlag =\n typeof includeDisabled === 'string'\n ? ['true', '1', 'yes'].includes(includeDisabled.toLowerCase())\n : false;\n\n const menus = await this.permissionService.getGroupsWithMenus(includeDisabledFlag);\n return RestUtilities.sendBaseResponse(res, menus);\n } catch (error) {\n return this.sendControllerError(res, error);\n }\n }\n\n @ApiOperation({\n summary: 'Recupera i ruoli e i menu di un utente',\n operationId: 'getUserRolesAndGrants',\n })\n @ApiOkResponse({ description: 'Elenco grant utente', type: UserGrantsResponse })\n @ApiResponse({ status: 200, description: 'Grant utente recuperati con successo', type: UserGrantsResponse })\n @ApiResponse({ status: 500, description: 'Errore interno del server', type: ErrorResponse })\n @Get('grants/:codiceUtente')\n async getUserRolesAndGrants(\n @Req() request: Request,\n @Param('codiceUtente', ParseIntPipe) codiceUtente: number,\n @Res() res: Response,\n ) {\n try {\n ensureSelfOrSuperUser(\n getAuthenticatedAccessiUser(request),\n codiceUtente,\n 'Puoi consultare solo i tuoi grant, salvo privilegi amministrativi.',\n );\n\n const menus = await this.permissionService.getUserRolesAndGrants(codiceUtente);\n return RestUtilities.sendBaseResponse(res, menus);\n } catch (error) {\n return this.sendControllerError(res, error);\n }\n }\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Request, Response } from 'express';
|
|
2
2
|
import { AccessiOptions } from '../AccessiModule';
|
|
3
|
-
import {
|
|
3
|
+
import { PublicRegisterRequest } from '../Dtos/PublicRegisterRequest';
|
|
4
4
|
import { SetStatoRegistrazioneDto } from '../Dtos/SetStatoRegistrazione';
|
|
5
5
|
import { UserDto } from '../Dtos/UserDto';
|
|
6
6
|
import { EmailService } from '../Services/EmailService/EmailService';
|
|
@@ -16,7 +16,7 @@ export declare class UserController {
|
|
|
16
16
|
getUsers(request: Request, res: Response, email?: string, codiceUtente?: number, includeExtensionFields?: boolean, includeGrants?: boolean): Promise<Response<any, Record<string, any>>>;
|
|
17
17
|
deleteUser(request: Request, codiceUtente: number, res: Response): Promise<Response<any, Record<string, any>>>;
|
|
18
18
|
setStatoRegistrazione(request: Request, body: SetStatoRegistrazioneDto, res: Response): Promise<Response<any, Record<string, any>>>;
|
|
19
|
-
register(request: Request, registrationData:
|
|
19
|
+
register(request: Request, registrationData: PublicRegisterRequest, res: Response): Promise<Response<any, Record<string, any>>>;
|
|
20
20
|
updateUtente(request: Request, codiceUtente: number, user: UserDto, res: Response): Promise<Response<any, Record<string, any>>>;
|
|
21
21
|
setGdpr(request: Request, codiceUtente: number, res: Response): Promise<Response<any, Record<string, any>>>;
|
|
22
22
|
}
|