From 834a3aa9598ca81088503032747ee5014acd1e4e Mon Sep 17 00:00:00 2001 From: vicent Date: Wed, 24 May 2023 15:16:04 +0200 Subject: [PATCH] =?UTF-8?q?refs=20#5554=20fix:=20eliminada=20transacci?= =?UTF-8?q?=C3=B3n=20en=20el=20back=20'renewToken'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- back/methods/vn-user/renew-token.js | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/back/methods/vn-user/renew-token.js b/back/methods/vn-user/renew-token.js index 66e64e995..ae5fa704e 100644 --- a/back/methods/vn-user/renew-token.js +++ b/back/methods/vn-user/renew-token.js @@ -8,25 +8,15 @@ module.exports = Self => { } }); - Self.renewToken = async function(ctx, options) { + Self.renewToken = async function(ctx) { const models = Self.app.models; const userId = ctx.req.accessToken.userId; const created = ctx.req.accessToken.created; // const tokenId = ctx.req.accessToken.id; - const myOptions = {}; - let tx; - - if (typeof options == 'object') - Object.assign(myOptions, options); - - if (!myOptions.transaction) { - tx = await Self.beginTransaction({}); - myOptions.transaction = tx; - } const now = new Date(); const differenceMilliseconds = now - created; - const differenceSeconds = Math.floor(differenceMilliseconds / 1000); // Convertir la diferencia a segundos + const differenceSeconds = Math.floor(differenceMilliseconds / 1000); const accessTokenConfig = await models.AccessTokenConfig.findOne(); if (differenceSeconds <= accessTokenConfig.renewPeriod) { @@ -39,9 +29,10 @@ module.exports = Self => { return response; } - const accessToken = await models.AccessToken.create({userId: userId}, myOptions); - await models.AccessToken.destroyAll({userId: userId}, myOptions); - // await models.AccessToken.destroyById(tokenId, myOptions); + await models.AccessToken.destroyAll({userId: userId}); + // await models.AccessToken.destroyById(tokenId); + + const accessToken = await models.AccessToken.create({userId: userId}); return {token: accessToken.id, created: accessToken.created}; };