#6744 fix worker setPassword #2027

Merged
jorgep merged 18 commits from 6744-fixWorkerSetPassword into dev 2024-03-15 09:48:14 +00:00
4 changed files with 7 additions and 5 deletions
Showing only changes of commit a94fd1a61c - Show all commits

View File

@ -221,5 +221,6 @@
"printerNotExists": "The printer does not exist",
"There are not picking tickets": "There are not picking tickets",
"ticketCommercial": "The ticket {{ ticket }} for the salesperson {{ salesMan }} is in preparation. (automatically generated message)",
"This password can only be changed by the user themselves": "This password can only be changed by the user themselves"
"This password can only be changed by the user themselves": "This password can only be changed by the user themselves",
"They're not your subordinate": "They're not your subordinate"
}

View File

@ -348,5 +348,6 @@
"Cmr file does not exist": "El archivo del cmr no existe",
"You are not allowed to modify the alias": "No estás autorizado a modificar el alias",
"The address of the customer must have information about Incoterms and Customs Agent": "El consignatario del cliente debe tener informado Incoterms y Agente de aduanas",
"This password can only be changed by the user themselves": "Esta contraseña solo puede ser modificada por el propio usuario"
"This password can only be changed by the user themselves": "Esta contraseña solo puede ser modificada por el propio usuario",
"They're not your subordinate": "No es tu subordinado/a."
}

View File

@ -1,4 +1,4 @@
const UserError = require('vn-loopback/util/user-error');
const ForbiddenError = require('vn-loopback/util/forbiddenError');
module.exports = Self => {
Self.remoteMethodCtx('setPassword', {
description: 'Set a new password',
@ -32,7 +32,7 @@ module.exports = Self => {
}
try {
const isSubordinate = await Self.isSubordinate(ctx, id, myOptions);
if (!isSubordinate) throw new UserError('You don\'t have enough privileges.');
if (!isSubordinate) throw new ForbiddenError('They\'re not your subordinate');
jorgep marked this conversation as resolved Outdated
Outdated
Review

Lanzar ForbiddenError indicando en el mensaje que no es subordinado.

Lanzar ForbiddenError indicando en el mensaje que no es subordinado.
jorgep marked this conversation as resolved Outdated

isHimself

isHimself
Outdated
Review

No pondría aquí isHimself, para cambiarse la contraseña uno mismo que se utilice el método tradicional que yahace las comprobaciones de seguridad correspondientes

No pondría aquí `isHimself`, para cambiarse la contraseña uno mismo que se utilice el método tradicional que yahace las comprobaciones de seguridad correspondientes
await models.Account.setUnverifiedPassword(id, newPass, myOptions);
jorgep marked this conversation as resolved
Review

no podemos poner aquí el contenido de setUnverifiedPassword?
es necesario crear ese método?

no podemos poner aquí el contenido de setUnverifiedPassword? es necesario crear ese método?
Review

me lo pidio exprasemente @juan

me lo pidio exprasemente @juan

View File

@ -54,7 +54,7 @@ describe('worker setPassword()', () => {
await models.Worker.setPassword(ctx, administrativeId, newPass, options);
await tx.rollback();
} catch (e) {
expect(e.message).toEqual(`You don't have enough privileges.`);
expect(e.message).toEqual(`They're not your subordinate`);
await tx.rollback();
}
});