From e830882c87bed65d3e2fcb02ce946adf2d1b1680 Mon Sep 17 00:00:00 2001 From: Rory Abraham Date: Thu, 17 Jun 2021 16:39:58 -0700 Subject: [PATCH] Fix migration and NABs --- src/libs/addEncryptedAuthTokenToURL.js | 5 +++-- src/libs/migrations/AddEncryptedAuthToken.js | 11 +++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/libs/addEncryptedAuthTokenToURL.js b/src/libs/addEncryptedAuthTokenToURL.js index a1ec0e4bc253..d7a06b6745f2 100644 --- a/src/libs/addEncryptedAuthTokenToURL.js +++ b/src/libs/addEncryptedAuthTokenToURL.js @@ -1,14 +1,15 @@ +import lodashGet from 'lodash/get'; import Onyx from 'react-native-onyx'; import ONYXKEYS from '../ONYXKEYS'; let encryptedAuthToken = ''; Onyx.connect({ key: ONYXKEYS.SESSION, - callback: session => encryptedAuthToken = session.encryptedAuthToken, + callback: session => encryptedAuthToken = lodashGet(session, 'encryptedAuthToken', ''), }); /** - * Add authToken to this attachment URL if necessary + * Add encryptedAuthToken to this attachment URL if necessary * * @param {String} url * @returns {String} diff --git a/src/libs/migrations/AddEncryptedAuthToken.js b/src/libs/migrations/AddEncryptedAuthToken.js index 522482d8048e..fe7730e26d81 100644 --- a/src/libs/migrations/AddEncryptedAuthToken.js +++ b/src/libs/migrations/AddEncryptedAuthToken.js @@ -3,8 +3,6 @@ import Onyx from 'react-native-onyx'; import ONYXKEYS from '../../ONYXKEYS'; import {reauthenticate} from '../API'; -const reauthenticateThrottled = _.throttle(reauthenticate, 5000); - /** * This migration adds an encryptedAuthToken to the SESSION key, if it is not present. * @@ -18,20 +16,21 @@ export default function () { Onyx.disconnect(connectionID); if (session && !_.isEmpty(session.encryptedAuthToken)) { - console.debug('[Onyx Migration] Skipped migration AddEncryptedAuthToken'); + console.debug('[Migrate Onyx] Skipped migration AddEncryptedAuthToken'); return resolve(); } if (!session || !session.authToken) { - console.debug('[Onyx Migration] Skipped migration AddEncryptedAuthToken'); + console.debug('[Migrate Onyx] Skipped migration AddEncryptedAuthToken'); return resolve(); } // If there is an auth token but no encrypted auth token, reauthenticate. if (session.authToken && _.isUndefined(session.encryptedAuthToken)) { - return reauthenticateThrottled('Onyx_Migration_AddEncryptedAuthToken') + return reauthenticate('Onyx_Migration_AddEncryptedAuthToken') .then(() => { - console.debug('[Onyx Migration] Ran migration AddEncryptedAuthToken'); + console.debug('[Migrate Onyx] Ran migration AddEncryptedAuthToken'); + resolve(); }); }