refactor: codigo reducido
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Vicent Llopis 2022-12-01 07:22:13 +01:00
parent ba8fe7dfa8
commit 444d495b7f
3 changed files with 17 additions and 13 deletions

View File

@ -248,7 +248,8 @@
"App locked": "Aplicación bloqueada por el usuario {{userId}}", "App locked": "Aplicación bloqueada por el usuario {{userId}}",
"Email verify": "Correo de verificación", "Email verify": "Correo de verificación",
"Landing cannot be lesser than shipment": "Landing cannot be lesser than shipment", "Landing cannot be lesser than shipment": "Landing cannot be lesser than shipment",
"Receipt's bank was not found": "No se encontró el banco del recibo", "Receipt's bank was not found": "No se encontró el banco del recibo",
"This receipt was not compensated": "Este recibo no ha sido compensado", "This receipt was not compensated": "Este recibo no ha sido compensado",
"Client's email was not found": "No se encontró el email del cliente" "Client's email was not found": "No se encontró el email del cliente",
"Aplicación bloqueada por el usuario 9": "Aplicación bloqueada por el usuario 9"
} }

View File

@ -41,12 +41,13 @@ module.exports = Self => {
} }
try { try {
const mdbApp = await models.MdbApp.findById(appName, null, myOptions); const mdbApp = await models.MdbApp.findById(appName, {fields: ['app', 'locked', 'userFk']}, myOptions);
const message = $t('App locked', { if (mdbApp.locked) {
userId: mdbApp.userFk throw new UserError($t('App locked', {
}); userId: mdbApp.userFk
if (mdbApp.locked) throw new UserError(message); }));
}
const updatedMdbApp = await mdbApp.updateAttributes({ const updatedMdbApp = await mdbApp.updateAttributes({
userFk: userId, userFk: userId,

View File

@ -64,10 +64,12 @@ module.exports = Self => {
let srcFile; let srcFile;
try { try {
const mdbApp = await models.MdbApp.findById(appName, null, myOptions); const mdbApp = await models.MdbApp.findById(appName, null, myOptions);
const message = $t('App locked', {
userId: mdbApp.userFk if (mdbApp.locked && mdbApp.userFk != userId) {
}); throw new UserError($t('App locked', {
if (mdbApp.locked && mdbApp.userFk != userId) throw new UserError(message); userId: mdbApp.userFk
}));
}
const tempContainer = await TempContainer.container('access'); const tempContainer = await TempContainer.container('access');
const uploaded = await TempContainer.upload(tempContainer.name, ctx.req, ctx.result, fileOptions); const uploaded = await TempContainer.upload(tempContainer.name, ctx.req, ctx.result, fileOptions);