From 79f54d5873d1d4e235449eac25dbf57e9a1279e7 Mon Sep 17 00:00:00 2001 From: Dean Date: Sun, 3 Jul 2022 22:14:18 +0100 Subject: [PATCH] Fix for oauth user db update --- packages/backend-core/src/auth.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/backend-core/src/auth.js b/packages/backend-core/src/auth.js index 9566a646f1..5a02446212 100644 --- a/packages/backend-core/src/auth.js +++ b/packages/backend-core/src/auth.js @@ -130,18 +130,22 @@ async function refreshOAuthToken(refreshToken, configType, configId) { } async function updateUserOAuth(userId, oAuthConfig) { - const details = { ...oAuthConfig } + const details = { + accessToken: oAuthConfig.accessToken, + refreshToken: oAuthConfig.refreshToken, + } + try { const db = getGlobalDB() - const dbUser = db.get(userId) + const dbUser = await db.get(userId) //Do not overwrite the refresh token if a valid one is not provided. if (typeof details.refreshToken !== "string") { delete details.refreshToken } - dbUser.oAuth2 = { - ...dbUser.oAuth2, + dbUser.oauth2 = { + ...dbUser.oauth2, ...details, }