7525-devToTest #2542
|
@ -27,17 +27,16 @@ module.exports = Self => {
|
||||||
const ticketCollection = await models.TicketCollection.findOne({
|
const ticketCollection = await models.TicketCollection.findOne({
|
||||||
include: {relation: 'collection'}, where: {ticketFk: id}
|
include: {relation: 'collection'}, where: {ticketFk: id}
|
||||||
}, myOptions);
|
}, myOptions);
|
||||||
let workerId = ticketCollection?.collection()?.workerFk;
|
let isOwner = ticketCollection?.collection()?.workerFk === ctx.req.accessToken.userId;
|
||||||
|
|
||||||
if (!workerId) {
|
if (!isOwner) {
|
||||||
const saleGroup = await models.SaleGroup.findOne({fields: ['id'], where: {ticketFk: id}}, myOptions);
|
const saleGroup = await models.SaleGroup.findOne({fields: ['id'], where: {ticketFk: id}}, myOptions);
|
||||||
const sectorCollectionSaleGroup = saleGroup && await models.SectorCollectionSaleGroup.findOne({
|
const sectorCollectionSaleGroup = saleGroup && await models.SectorCollectionSaleGroup.findOne({
|
||||||
include: {relation: 'sectorCollection'}, where: {saleGroupFk: saleGroup.id}
|
include: {relation: 'sectorCollection'}, where: {saleGroupFk: saleGroup.id}
|
||||||
}, myOptions);
|
}, myOptions);
|
||||||
|
|
||||||
workerId = sectorCollectionSaleGroup?.sectorCollection()?.userFk;
|
isOwner = sectorCollectionSaleGroup?.sectorCollection()?.userFk === ctx.req.accessToken.userId;
|
||||||
}
|
}
|
||||||
const isOwner = workerId === ctx.req.accessToken.userId;
|
|
||||||
|
|
||||||
if (!ticket)
|
if (!ticket)
|
||||||
throw new ForbiddenError(`The ticket doesn't exist.`);
|
throw new ForbiddenError(`The ticket doesn't exist.`);
|
||||||
|
|
Loading…
Reference in New Issue