From 7635230c882a1c1726f05c90226bc99f483c8ba3 Mon Sep 17 00:00:00 2001 From: lohxt1 Date: Tue, 25 Mar 2025 18:29:44 +0530 Subject: [PATCH] oauth2 fixes --- .../providers/ReduxStore/slices/collections/actions.js | 5 +++-- packages/bruno-electron/src/ipc/collection.js | 10 ---------- packages/bruno-electron/src/store/oauth2.js | 1 + 3 files changed, 4 insertions(+), 12 deletions(-) diff --git a/packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js b/packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js index fdf6b42c1..1d6678ab6 100644 --- a/packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js +++ b/packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js @@ -50,6 +50,7 @@ import { sendCollectionOauth2Request as _sendCollectionOauth2Request } from 'uti import { getGlobalEnvironmentVariables } from 'utils/collections/index'; import { findCollectionByPathname, findEnvironmentInCollectionByName } from 'utils/collections/index'; import { sanitizeName } from 'utils/common/regex'; +import { safeParseJSON, safeStringifyJSON } from 'utils/common/index'; export const renameCollection = (newName, collectionUid) => (dispatch, getState) => { const state = getState(); @@ -1281,7 +1282,7 @@ export const fetchOauth2Credentials = (payload) => async (dispatch, getState) => url, collectionUid, credentialsId, - debugInfo, + debugInfo: safeParseJSON(safeStringifyJSON(debugInfo)), folderUid: folderUid || null, itemUid: !folderUid ? itemUid : null }) @@ -1304,7 +1305,7 @@ export const refreshOauth2Credentials = (payload) => async (dispatch, getState) url, collectionUid, credentialsId, - debugInfo, + debugInfo: safeParseJSON(safeStringifyJSON(debugInfo)), folderUid: folderUid || null, itemUid: !folderUid ? itemUid : null }) diff --git a/packages/bruno-electron/src/ipc/collection.js b/packages/bruno-electron/src/ipc/collection.js index c1516af17..112d1c070 100644 --- a/packages/bruno-electron/src/ipc/collection.js +++ b/packages/bruno-electron/src/ipc/collection.js @@ -902,16 +902,6 @@ const registerRendererEventHandlers = (mainWindow, watcher, lastOpenedCollection } }); - ipcMain.handle('renderer:get-stored-oauth2-credentials', async (event, collectionUid, url, credentialsId) => { - try { - const oauth2Store = new Oauth2Store(); - const credentials = oauth2Store.getCredentialsForCollection({ collectionUid, url, credentialsId }); - return { credentials, collectionUid, url }; - } catch (error) { - return Promise.reject(error); - } - }); - ipcMain.handle('renderer:fetch-oauth2-credentials', async (event, { itemUid, request, collection }) => { try { if (request.oauth2) { diff --git a/packages/bruno-electron/src/store/oauth2.js b/packages/bruno-electron/src/store/oauth2.js index d3621cc2d..8c009db7b 100644 --- a/packages/bruno-electron/src/store/oauth2.js +++ b/packages/bruno-electron/src/store/oauth2.js @@ -118,6 +118,7 @@ class Oauth2Store { try { let oauth2DataForCollection = this.getOauth2DataOfCollection({ collectionUid, url }); let credentials = oauth2DataForCollection?.credentials?.find(c => (c?.url == url) && (c?.credentialsId == credentialsId)); + if (!credentials?.data) return null; let decryptedCredentialsData = safeParseJSON(decryptString(credentials?.data)); return decryptedCredentialsData; } catch (err) {