#6744 fix worker setPassword #2027
|
@ -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"
|
||||
}
|
||||
|
|
|
@ -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."
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
||||
jorgep marked this conversation as resolved
Outdated
jgallego
commented
isHimself isHimself
juan
commented
No pondría aquí 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
jgallego
commented
no podemos poner aquí el contenido de setUnverifiedPassword? no podemos poner aquí el contenido de setUnverifiedPassword?
es necesario crear ese método?
jorgep
commented
me lo pidio exprasemente @juan me lo pidio exprasemente @juan
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue
Lanzar ForbiddenError indicando en el mensaje que no es subordinado.