refacto(controller): remove uid in req body for updates (#62)
solve this ticket: https://www.notion.so/smart-chain/8451b1abb95046ceae81b49cfe26fe71?v=ac57690f41144dd8b703ad8ce35b8f3f&p=ad10ff9447294f139cceab862d94c964&pm=s
This commit is contained in:
commit
78fe4c0e55
862
package-lock.json
generated
862
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -52,7 +52,7 @@
|
|||||||
"cron": "^2.3.1",
|
"cron": "^2.3.1",
|
||||||
"express": "^4.18.2",
|
"express": "^4.18.2",
|
||||||
"jsonwebtoken": "^9.0.0",
|
"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",
|
"module-alias": "^2.2.2",
|
||||||
"multer": "^1.4.5-lts.1",
|
"multer": "^1.4.5-lts.1",
|
||||||
"next": "^13.1.5",
|
"next": "^13.1.5",
|
||||||
|
@ -8,7 +8,6 @@ import { Prisma } from "@prisma/client";
|
|||||||
import authHandler from "@App/middlewares/AuthHandler";
|
import authHandler from "@App/middlewares/AuthHandler";
|
||||||
import ruleHandler from "@App/middlewares/RulesHandler";
|
import ruleHandler from "@App/middlewares/RulesHandler";
|
||||||
import userHandler from "@App/middlewares/OfficeMembershipHandlers/UserHandler";
|
import userHandler from "@App/middlewares/OfficeMembershipHandlers/UserHandler";
|
||||||
import { validateOrReject } from "class-validator";
|
|
||||||
import roleHandler from "@App/middlewares/RolesHandler";
|
import roleHandler from "@App/middlewares/RolesHandler";
|
||||||
import RolesService from "@Services/admin/RolesService/RolesService";
|
import RolesService from "@Services/admin/RolesService/RolesService";
|
||||||
import OfficeRolesService from "@Services/admin/OfficeRolesService/OfficeRolesService";
|
import OfficeRolesService from "@Services/admin/OfficeRolesService/OfficeRolesService";
|
||||||
@ -87,9 +86,6 @@ export default class UsersController extends ApiController {
|
|||||||
//init IUser resource with request body values
|
//init IUser resource with request body values
|
||||||
const userEntity = User.hydrate<User>(req.body);
|
const userEntity = User.hydrate<User>(req.body);
|
||||||
|
|
||||||
//validate user
|
|
||||||
await validateOrReject(userEntity, { groups: ["updateUser"] });
|
|
||||||
|
|
||||||
if(userEntity.role) {
|
if(userEntity.role) {
|
||||||
const role = await this.roleService.getByUid(userEntity.role.uid!);
|
const role = await this.roleService.getByUid(userEntity.role.uid!);
|
||||||
if(!role) {
|
if(!role) {
|
||||||
|
@ -135,9 +135,6 @@ export default class FilesController extends ApiController {
|
|||||||
//init File resource with request body values
|
//init File resource with request body values
|
||||||
const fileEntity = File.hydrate<File>(req.body);
|
const fileEntity = File.hydrate<File>(req.body);
|
||||||
|
|
||||||
//validate file
|
|
||||||
await validateOrReject(fileEntity, { groups: ["updateFile"] });
|
|
||||||
|
|
||||||
//call service to get prisma entity
|
//call service to get prisma entity
|
||||||
const fileEntityUpdated: Files = await this.filesService.update(uid, fileEntity);
|
const fileEntityUpdated: Files = await this.filesService.update(uid, fileEntity);
|
||||||
|
|
||||||
|
@ -94,8 +94,7 @@ export default class OfficesController extends ApiController {
|
|||||||
}
|
}
|
||||||
//init IUser resource with request body values
|
//init IUser resource with request body values
|
||||||
const officeEntity = OfficeResource.hydrate<OfficeResource>(req.body);
|
const officeEntity = OfficeResource.hydrate<OfficeResource>(req.body);
|
||||||
//validate user
|
|
||||||
await validateOrReject(officeEntity, { groups: ["updateOffice"] });
|
|
||||||
//call service to get prisma entity
|
//call service to get prisma entity
|
||||||
const officeEntityUpdated = await this.officesService.update(uid, officeEntity);
|
const officeEntityUpdated = await this.officesService.update(uid, officeEntity);
|
||||||
//Hydrate ressource with prisma entity
|
//Hydrate ressource with prisma entity
|
||||||
|
@ -92,9 +92,6 @@ export default class RulesController extends ApiController {
|
|||||||
//init IRule resource with request body values
|
//init IRule resource with request body values
|
||||||
const ruleEntity = Rule.hydrate<Rule>(req.body);
|
const ruleEntity = Rule.hydrate<Rule>(req.body);
|
||||||
|
|
||||||
//validate rule
|
|
||||||
await validateOrReject(ruleEntity, { groups: ["updateRule"] });
|
|
||||||
|
|
||||||
//call service to get prisma entity
|
//call service to get prisma entity
|
||||||
const ruleEntityUpdated = await this.rulesService.update(ruleEntity);
|
const ruleEntityUpdated = await this.rulesService.update(ruleEntity);
|
||||||
|
|
||||||
|
@ -109,9 +109,6 @@ export default class UsersController extends ApiController {
|
|||||||
//init IUser resource with request body values
|
//init IUser resource with request body values
|
||||||
const userEntity = User.hydrate<User>(req.body);
|
const userEntity = User.hydrate<User>(req.body);
|
||||||
|
|
||||||
//validate user
|
|
||||||
await validateOrReject(userEntity, { groups: ["updateUser"] });
|
|
||||||
|
|
||||||
if(userEntity.role) {
|
if(userEntity.role) {
|
||||||
const role = await this.roleService.getByUid(userEntity.role.uid!);
|
const role = await this.roleService.getByUid(userEntity.role.uid!);
|
||||||
if(!role) {
|
if(!role) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user