diff --git a/loopback/common/methods/application/checkColumnPermission.js b/loopback/common/methods/application/checkColumnPermission.js index 309fc375f6..669ec91ff9 100644 --- a/loopback/common/methods/application/checkColumnPermission.js +++ b/loopback/common/methods/application/checkColumnPermission.js @@ -43,11 +43,8 @@ module.exports = Self => { Self.checkColumnPermission = async(schema, table, column, privilegeType, userId) => { const models = Self.app.models; - const $t = ((msg, vars) => // Me falta hacer funcionar el $t, ya que probando con ctx no funciona - msg.replace(/\{(\w+)\}/g, (_, key) => vars[key] || '') - ); - const user = await models.VnUser.findById(userId); + if (!user) return; const role = await models.VnRole.findById(user.roleFk); const permissions = await Self.rawSql(` SELECT TRUE @@ -60,6 +57,6 @@ module.exports = Self => { `, [schema, table, column, privilegeType, role.name]); if (!permissions.length) - throw new UserError($t(`You don't have enough privileges to modify`, {column})); + throw new UserError(`You do not have sufficient privileges to modify a specific column`); }; }; diff --git a/loopback/locale/en.json b/loopback/locale/en.json index f1df14f7d5..e6ec52d638 100644 --- a/loopback/locale/en.json +++ b/loopback/locale/en.json @@ -249,6 +249,5 @@ "Sales already moved": "Sales already moved", "Holidays to past days not available": "Holidays to past days not available", "Price cannot be blank": "Price cannot be blank", - "There are tickets to be invoiced": "There are tickets to be invoiced", - "You don't have enough privileges to modify": "You don't have enough privileges to modify: {{column}}" + "There are tickets to be invoiced": "There are tickets to be invoiced" } diff --git a/loopback/locale/es.json b/loopback/locale/es.json index 43a127fdbf..33e201d125 100644 --- a/loopback/locale/es.json +++ b/loopback/locale/es.json @@ -399,5 +399,5 @@ "All tickets have a route order": "Todos los tickets tienen orden de ruta", "Price cannot be blank": "Price cannot be blank", "There are tickets to be invoiced": "La zona tiene tickets por facturar", - "You don't have enough privileges to modify": "No tienes suficientes permisos para modificar la columna: {{column}}" + "You do not have sufficient privileges to modify a specific column": "No tienes suficientes permisos para modificar una columna específica" } \ No newline at end of file diff --git a/loopback/locale/fr.json b/loopback/locale/fr.json index 14c2bcd79c..9941358be6 100644 --- a/loopback/locale/fr.json +++ b/loopback/locale/fr.json @@ -366,6 +366,5 @@ "The quantity claimed cannot be greater than the quantity of the line": "Le montant réclamé ne peut pas être supérieur au montant de la ligne", "You do not have permission to modify the booked field": "Vous n'avez pas la permission de modifier le champ comptabilisé", "ticketLostExpedition": "Le ticket [{{ticketId}}]({{{ticketUrl}}}) a l'expédition perdue suivante : {{expeditionId}}", - "The web user's email already exists": "L'email de l'internaute existe déjà", - "You don't have enough privileges to modify": "Vous n'avez pas suffisamment de privilèges pour modifier: {{column}}" + "The web user's email already exists": "L'email de l'internaute existe déjà" } diff --git a/loopback/locale/pt.json b/loopback/locale/pt.json index 569f47a965..e84b30f3d1 100644 --- a/loopback/locale/pt.json +++ b/loopback/locale/pt.json @@ -365,6 +365,5 @@ "Cannot send mail": "Não é possível enviar o email", "The quantity claimed cannot be greater than the quantity of the line": "O valor reclamado não pode ser superior ao valor da linha", "ticketLostExpedition": "O ticket [{{ticketId}}]({{{ticketUrl}}}) tem a seguinte expedição perdida: {{expeditionId}}", - "The web user's email already exists": "O e-mail do utilizador da web já existe.", - "You don't have enough privileges to modify": "Você não tem privilégios suficientes para modificar: {{column}}" + "The web user's email already exists": "O e-mail do utilizador da web já existe." } diff --git a/modules/item/back/models/item.js b/modules/item/back/models/item.js index 4065fb8b16..7f9c121d51 100644 --- a/modules/item/back/models/item.js +++ b/modules/item/back/models/item.js @@ -23,9 +23,11 @@ module.exports = Self => { Self.observe('before save', async function(ctx) { await Self.availableId(ctx); - await models.Application.checkColumnPermission( - 'vn', 'item', 'packingOut', 'UPDATE', ctx.options.accessToken.userId - ); + if (!(ctx?.data?.packingOut === undefined)) { + await models.Application.checkColumnPermission( + 'vn', 'item', 'packingOut', 'UPDATE', ctx.options.accessToken.userId + ); + } }); Self.availableId = async function(ctx) {