Fix upgrade accounts so they don't overwrite each other.
This commit is contained in:
parent
56bff1db41
commit
484e09e4ff
1 changed files with 8 additions and 8 deletions
|
|
@ -163,6 +163,7 @@ angular.module('copayApp.services')
|
||||||
// Needs upgrade
|
// Needs upgrade
|
||||||
upgraded += ' ' + key;
|
upgraded += ' ' + key;
|
||||||
var acctData = {
|
var acctData = {
|
||||||
|
acct: data[key],
|
||||||
token: data[key]['bitpayDebitCards-' + network].token,
|
token: data[key]['bitpayDebitCards-' + network].token,
|
||||||
email: key
|
email: key
|
||||||
};
|
};
|
||||||
|
|
@ -274,18 +275,17 @@ angular.module('copayApp.services')
|
||||||
data = JSON.parse(data);
|
data = JSON.parse(data);
|
||||||
}
|
}
|
||||||
data = data || {};
|
data = data || {};
|
||||||
if (lodash.isEmpty(data) || !data.email) return cb('No account to set');
|
if (lodash.isEmpty(data) || !data.email || !data.acct) return cb('No account to set');
|
||||||
storage.get('bitpayAccounts-' + network, function(err, bitpayAccounts) {
|
storage.get('bitpayAccounts-v2-' + network, function(err, bitpayAccounts) {
|
||||||
if (err) return cb(err);
|
if (err) return cb(err);
|
||||||
if (lodash.isString(bitpayAccounts)) {
|
if (lodash.isString(bitpayAccounts)) {
|
||||||
bitpayAccounts = JSON.parse(bitpayAccounts);
|
bitpayAccounts = JSON.parse(bitpayAccounts);
|
||||||
}
|
}
|
||||||
// Ensure only the specified account is set (data.email)
|
bitpayAccounts = bitpayAccounts || {};
|
||||||
var upgradedBitpayAccount = {};
|
bitpayAccounts[data.email] = data.acct;
|
||||||
upgradedBitpayAccount[data.email] = bitpayAccounts[data.email] || {};
|
bitpayAccounts[data.email]['bitpayApi-' + network] = {};
|
||||||
upgradedBitpayAccount[data.email]['bitpayApi-' + network] = {};
|
bitpayAccounts[data.email]['bitpayApi-' + network].token = data.token;
|
||||||
upgradedBitpayAccount[data.email]['bitpayApi-' + network].token = data.token;
|
storage.set('bitpayAccounts-v2-' + network, JSON.stringify(bitpayAccounts), cb);
|
||||||
storage.set('bitpayAccounts-v2-' + network, JSON.stringify(upgradedBitpayAccount), cb);
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue