try
gitea/salix/pipeline/head There was a failure building this commit Details

This commit is contained in:
Alex Moreno 2022-10-25 15:02:22 +02:00
parent e1e13468a9
commit 342832c475
3 changed files with 14 additions and 19 deletions

View File

@ -1,3 +1,3 @@
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`)
VALUES
('Sale', 'editTracked', 'READ', 'ALLOW', 'ROLE', 'production');
('Sale', 'editTracked', 'WRITE', 'ALLOW', 'ROLE', 'production');

View File

@ -27,25 +27,20 @@ module.exports = Self => {
if (typeof options == 'object')
Object.assign(myOptions, options);
const firstSale = await models.Sale.findById(sales[0], null, myOptions);
const isTicketEditable = await models.Ticket.isEditable(ctx, firstSale.ticketFk, myOptions);
if (!isTicketEditable)
throw new UserError(`The sales of this ticket can't be modified`);
console.log(ctx.req.accessToken);
const token = ctx.req.accessToken;
let canEditTracked = await models.ACL.checkAccessForToken(token, models.Sale, null, 'refund');
// const newCtx = ctx;
// newCtx.property = 'refund';
// newCtx.accessType = 'WRITE';
// newCtx.methodNames = ['refund'];
// newCtx.model = await models.Sale;
const saleTracking = await models.SaleTracking.find({where: {saleFk: {inq: sales}}}, myOptions);
const hasSaleTracking = saleTracking.length;
const saleCloned = await models.SaleCloned.find({where: {saleClonedFk: {inq: sales}}}, myOptions);
const hasSaleCloned = saleCloned.length;
const isTicketWeekly =
await models.TicketWeekly.findOne({where: {ticketFk: firstSale.ticketFk}}, myOptions);
// (principalType, principalId,model, property, accessType,callback);
// let canEditTracked = await models.ACL.checkPermission('ROLE', 'employee', 'Sale', 'editTracked', 'WRITE');
// let canEditTracked = await models.ACL.checkAccessForContext(newCtx);
console.log(canEditTracked);
// let canEditTracked2 = await models.ACL.checkPermission('USER', 'developer', 'Sale', 'editTracked', 'READ');
const array = ['editTracked'];
/* const array = ['editTracked'];
const AccessContext = loopBackCtx.AccessContext;
const toFind = {
principals: [{
@ -90,6 +85,6 @@ module.exports = Self => {
if (canEdit)
return true;
return false;
return false;*/
};
};

View File

@ -26,7 +26,7 @@
"jsdom": "^16.7.0",
"jszip": "^3.10.0",
"ldapjs": "^2.2.0",
"loopback": "^3.26.0",
"loopback": "^3.28.0",
"loopback-boot": "3.3.1",
"loopback-component-explorer": "^6.5.0",
"loopback-component-storage": "3.6.1",