fix deed middleware
This commit is contained in:
parent
d47b375957
commit
6168683cfe
@ -2,7 +2,7 @@ import HttpCodes from "@Common/system/controller-pattern/HttpCodes";
|
|||||||
import { NextFunction, Request, Response } from "express";
|
import { NextFunction, Request, Response } from "express";
|
||||||
import Container from "typedi";
|
import Container from "typedi";
|
||||||
import OfficeFoldersService from "@Services/super-admin/OfficeFoldersService/OfficeFoldersService";
|
import OfficeFoldersService from "@Services/super-admin/OfficeFoldersService/OfficeFoldersService";
|
||||||
import DeedTypesService from "@Services/super-admin/DeedTypesService/DeedTypesService";
|
import DeedsService from "@Services/super-admin/DeedsService/DeedsService";
|
||||||
|
|
||||||
export default async function folderHandler(req: Request, response: Response, next: NextFunction) {
|
export default async function folderHandler(req: Request, response: Response, next: NextFunction) {
|
||||||
const officeId = req.body.user.office_Id;
|
const officeId = req.body.user.office_Id;
|
||||||
@ -17,13 +17,13 @@ export default async function folderHandler(req: Request, response: Response, ne
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (deed) {
|
if (deed) {
|
||||||
const deedTypeService = Container.get(DeedTypesService);
|
const deedService = Container.get(DeedsService);
|
||||||
const deedTypeWithOffice = await deedTypeService.getByUidWithOffice(deed.deedType.uid!);
|
const deedWithOffice = await deedService.getByUidWithOffice(deed.uid!);
|
||||||
if (!deedTypeWithOffice) {
|
if (!deedWithOffice) {
|
||||||
response.sendStatus(HttpCodes.NOT_FOUND);
|
response.sendStatus(HttpCodes.NOT_FOUND);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (deedTypeWithOffice.office.uid != officeId) {
|
if (deedWithOffice.deed_type.office.uid != officeId) {
|
||||||
response.sendStatus(HttpCodes.UNAUTHORIZED);
|
response.sendStatus(HttpCodes.UNAUTHORIZED);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ export default class DeedsService extends BaseService {
|
|||||||
return this.deedRepository.findOneByUid(uid, query);
|
return this.deedRepository.findOneByUid(uid, query);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async getOneByUidWithOffice(uid: string) {
|
public async getByUidWithOffice(uid: string) {
|
||||||
return this.deedRepository.findOneByUidWithOffice(uid);
|
return this.deedRepository.findOneByUidWithOffice(uid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user