remove uid in req body for updates

This commit is contained in:
OxSaitama 2023-08-16 13:53:32 +02:00
parent b1c00f1b27
commit 1ce013b5f6
7 changed files with 460 additions and 420 deletions

862
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -52,7 +52,7 @@
"cron": "^2.3.1",
"express": "^4.18.2",
"jsonwebtoken": "^9.0.0",
"le-coffre-resources": "git@github.com:smart-chain-fr/leCoffre-resources.git#v2.66",
"le-coffre-resources": "git@github.com:smart-chain-fr/leCoffre-resources.git#v2.67",
"module-alias": "^2.2.2",
"multer": "^1.4.5-lts.1",
"next": "^13.1.5",

View File

@ -8,7 +8,6 @@ import { Prisma } from "@prisma/client";
import authHandler from "@App/middlewares/AuthHandler";
import ruleHandler from "@App/middlewares/RulesHandler";
import userHandler from "@App/middlewares/OfficeMembershipHandlers/UserHandler";
import { validateOrReject } from "class-validator";
import roleHandler from "@App/middlewares/RolesHandler";
import RolesService from "@Services/admin/RolesService/RolesService";
import OfficeRolesService from "@Services/admin/OfficeRolesService/OfficeRolesService";
@ -87,9 +86,6 @@ export default class UsersController extends ApiController {
//init IUser resource with request body values
const userEntity = User.hydrate<User>(req.body);
//validate user
await validateOrReject(userEntity, { groups: ["updateUser"] });
if(userEntity.role) {
const role = await this.roleService.getByUid(userEntity.role.uid!);
if(!role) {

View File

@ -135,9 +135,6 @@ export default class FilesController extends ApiController {
//init File resource with request body values
const fileEntity = File.hydrate<File>(req.body);
//validate file
await validateOrReject(fileEntity, { groups: ["updateFile"] });
//call service to get prisma entity
const fileEntityUpdated: Files = await this.filesService.update(uid, fileEntity);

View File

@ -94,8 +94,7 @@ export default class OfficesController extends ApiController {
}
//init IUser resource with request body values
const officeEntity = OfficeResource.hydrate<OfficeResource>(req.body);
//validate user
await validateOrReject(officeEntity, { groups: ["updateOffice"] });
//call service to get prisma entity
const officeEntityUpdated = await this.officesService.update(uid, officeEntity);
//Hydrate ressource with prisma entity

View File

@ -92,9 +92,6 @@ export default class RulesController extends ApiController {
//init IRule resource with request body values
const ruleEntity = Rule.hydrate<Rule>(req.body);
//validate rule
await validateOrReject(ruleEntity, { groups: ["updateRule"] });
//call service to get prisma entity
const ruleEntityUpdated = await this.rulesService.update(ruleEntity);

View File

@ -109,9 +109,6 @@ export default class UsersController extends ApiController {
//init IUser resource with request body values
const userEntity = User.hydrate<User>(req.body);
//validate user
await validateOrReject(userEntity, { groups: ["updateUser"] });
if(userEntity.role) {
const role = await this.roleService.getByUid(userEntity.role.uid!);
if(!role) {