From bba893cdd4914fa856a0e3755b0817a0ae876830 Mon Sep 17 00:00:00 2001 From: Pau Navarro Date: Tue, 7 Feb 2023 09:45:04 +0100 Subject: [PATCH] fix bug on jwt not updating --- utils.js | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/utils.js b/utils.js index 9f01908..3275766 100644 --- a/utils.js +++ b/utils.js @@ -81,17 +81,13 @@ async function getClientToken() { async function updateClientConfig(clientId, clientSecret, accessToken, tokenExpirationDate) { try { console.log('Updating the client config with the new token...'); - await models.clientConfig.findOrCreate({ - where: { - id: 1, - }, - defaults: { - clientId: clientId, - clientSecret: clientSecret, - currentToken: accessToken, - tokenExpiration: tokenExpirationDate, - requestLimit: 500, - }, + await models.clientConfig.upsert({ + id: 1, + clientId: clientId, + clientSecret: clientSecret, + currentToken: accessToken, + tokenExpiration: tokenExpirationDate, + requestLimit: 500, }); console.log('Client config updated, new Token set'); console.log('New token expiration date: ', tokenExpirationDate);