Merge branch 'dev' of github.com:smart-chain-fr/leCoffre into dev
This commit is contained in:
commit
94e1eb24d4
@ -2,7 +2,7 @@ import { Response, Request } from "express";
|
||||
import { Controller, Get, Post } from "@ControllerPattern/index";
|
||||
import ApiController from "@Common/system/controller-pattern/ApiController";
|
||||
import { Service } from "typedi";
|
||||
import { OfficeFolder } from "le-coffre-resources/dist/Notary";
|
||||
import { Document, OfficeFolder } from "le-coffre-resources/dist/Notary";
|
||||
import { getFolderHashes } from "@Common/optics/notary";
|
||||
import OfficeFoldersService from "@Services/notary/OfficeFoldersService/OfficeFoldersService";
|
||||
import OfficeFolderAnchorsRepository from "@Repositories/OfficeFolderAnchorsRepository";
|
||||
@ -136,6 +136,18 @@ export default class OfficeFoldersController extends ApiController {
|
||||
|
||||
const officeFolder = OfficeFolder.hydrate<OfficeFolder>(officeFolderFound, { strategy: "excludeAll" });
|
||||
|
||||
// Check if every document is validated in a folder
|
||||
const documents = officeFolder.documents ?? [];
|
||||
const documentsValidated = documents.filter((document) => {
|
||||
let documentHydrated = Document.hydrate<Document>(document, { strategy: "excludeAll" });
|
||||
return documentHydrated.document_status === "VALIDATED";
|
||||
});
|
||||
|
||||
if (documentsValidated.length !== documents.length && documents.length !== 0) {
|
||||
this.httpBadRequest(response, "Cannot anchor a folder with non validated documents");
|
||||
return;
|
||||
}
|
||||
|
||||
const folderHashes = getFolderHashes(officeFolder);
|
||||
|
||||
if (folderHashes.length === 0) {
|
||||
|
@ -128,11 +128,10 @@ export default class UsersController extends ApiController {
|
||||
return;
|
||||
}
|
||||
|
||||
// Not needed if you're super admin you can assign every roles from every offices
|
||||
// if (officeRole.office_uid != userFound.office_uid) {
|
||||
// this.httpBadRequest(response, "Cannot assign an office role from another office");
|
||||
// return;
|
||||
// }
|
||||
if (officeRole.office_uid != userFound.office_uid) {
|
||||
this.httpBadRequest(response, "Cannot assign an office role from another office");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//call service to get prisma entity
|
||||
|
Loading…
x
Reference in New Issue
Block a user