fix: refs #7917 fix methods, tests, acls #3085
|
@ -36,13 +36,7 @@ module.exports = Self => {
|
||||||
arg: 'to',
|
arg: 'to',
|
||||||
type: 'date',
|
type: 'date',
|
||||||
description: 'The to date filter',
|
description: 'The to date filter',
|
||||||
},
|
}
|
||||||
{
|
|
||||||
arg: 'userId',
|
|
||||||
type: 'integer',
|
|
||||||
description: 'The user id',
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
returns: {
|
returns: {
|
||||||
type: ['object'],
|
type: ['object'],
|
||||||
|
@ -55,8 +49,6 @@ module.exports = Self => {
|
||||||
});
|
});
|
||||||
|
|
||||||
Self.filter = async(ctx, filter, options) => {
|
Self.filter = async(ctx, filter, options) => {
|
||||||
const models = Self.app.models;
|
|
||||||
const userId = ctx.req.accessToken.userId;
|
|
||||||
const conn = Self.dataSource.connector;
|
const conn = Self.dataSource.connector;
|
||||||
const myOptions = {};
|
const myOptions = {};
|
||||||
|
|
||||||
|
@ -80,14 +72,7 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
filter = mergeFilters(ctx.args?.filter ?? {}, {where});
|
filter = mergeFilters(filter, {where});
|
||||||
const getRouteByAgency = await models.ACL.checkAccessAcl(ctx, 'Route', 'getRouteByAgency', 'WRITE');
|
|
||||||
|
|
||||||
const supplier = await models.Supplier.isSupplier(userId, myOptions);
|
|
||||||
if (supplier && getRouteByAgency) {
|
|
||||||
if (!filter.where) filter.where = {};
|
|
||||||
filter.where[`a.supplierFk`] = supplier.id;
|
|
||||||
}
|
|
||||||
|
|
||||||
const date = Date.vnNew();
|
const date = Date.vnNew();
|
||||||
carlossa marked this conversation as resolved
Outdated
|
|||||||
date.setHours(0, 0, 0, 0);
|
date.setHours(0, 0, 0, 0);
|
||||||
|
@ -130,6 +115,7 @@ module.exports = Self => {
|
||||||
const sql = ParameterizedSQL.join(stmts, ';');
|
const sql = ParameterizedSQL.join(stmts, ';');
|
||||||
const result = await conn.executeStmt(sql, myOptions);
|
const result = await conn.executeStmt(sql, myOptions);
|
||||||
|
|
||||||
|
const models = Self.app.models;
|
||||||
for (let agencyTerm of result)
|
for (let agencyTerm of result)
|
||||||
agencyTerm.route = await models.Route.findById(agencyTerm.routeFk);
|
agencyTerm.route = await models.Route.findById(agencyTerm.routeFk);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
crear acl getRouteByAgency, comprobar los acl de mas a menos permisivo.
esta part de la tarea no la veig implementada