From 56bff1db411176533db69923cb95a25c7bcca22b Mon Sep 17 00:00:00 2001 From: Andy Phillipson Date: Tue, 24 Jan 2017 10:08:31 -0500 Subject: [PATCH] Upgrade only one account at a time. --- src/js/services/storageService.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/js/services/storageService.js b/src/js/services/storageService.js index 55a675df3..520747d0c 100644 --- a/src/js/services/storageService.js +++ b/src/js/services/storageService.js @@ -280,11 +280,12 @@ angular.module('copayApp.services') if (lodash.isString(bitpayAccounts)) { bitpayAccounts = JSON.parse(bitpayAccounts); } - bitpayAccounts = bitpayAccounts || {}; - bitpayAccounts[data.email] = bitpayAccounts[data.email] || {}; - bitpayAccounts[data.email]['bitpayApi-' + network] = bitpayAccounts[data.email]['bitpayApi-' + network] || {}; - bitpayAccounts[data.email]['bitpayApi-' + network].token = data.token; - storage.set('bitpayAccounts-v2-' + network, JSON.stringify(bitpayAccounts), cb); + // Ensure only the specified account is set (data.email) + var upgradedBitpayAccount = {}; + upgradedBitpayAccount[data.email] = bitpayAccounts[data.email] || {}; + upgradedBitpayAccount[data.email]['bitpayApi-' + network] = {}; + upgradedBitpayAccount[data.email]['bitpayApi-' + network].token = data.token; + storage.set('bitpayAccounts-v2-' + network, JSON.stringify(upgradedBitpayAccount), cb); }); };