Perform deep object verification on bitpayAccounts-v2. Ensure that nextStep for bitpay card is visible when no cards are cached.
This commit is contained in:
parent
17210d52bb
commit
91b6d2774b
2 changed files with 21 additions and 6 deletions
|
|
@ -289,6 +289,8 @@ angular.module('copayApp.controllers').controller('tabHomeController',
|
||||||
if (err) return;
|
if (err) return;
|
||||||
if (lodash.isEmpty(data)) {
|
if (lodash.isEmpty(data)) {
|
||||||
$scope.bitpayCards = null;
|
$scope.bitpayCards = null;
|
||||||
|
// Ensure next step for cards is visible
|
||||||
|
storageService.setNextStep('BitpayCard', 'false', function(err) {});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$scope.bitpayCards = data;
|
$scope.bitpayCards = data;
|
||||||
|
|
|
||||||
|
|
@ -200,14 +200,27 @@ angular.module('copayApp.services')
|
||||||
var verified = '';
|
var verified = '';
|
||||||
var toRemove = [];
|
var toRemove = [];
|
||||||
_asyncEach(Object.keys(data), function(key, callback) {
|
_asyncEach(Object.keys(data), function(key, callback) {
|
||||||
|
// Verify account API data
|
||||||
if (!data[key]['bitpayApi-' + network] ||
|
if (!data[key]['bitpayApi-' + network] ||
|
||||||
!data[key]['bitpayDebitCards-' + network]) {
|
!data[key]['bitpayApi-' + network].token) {
|
||||||
// Invalid entry - 'bitpayApi-' key missing
|
// Invalid entry - one or more keys are missing
|
||||||
// Invalid entry - 'bitpayDebitCards-' key missing
|
|
||||||
toRemove.push(key);
|
toRemove.push(key);
|
||||||
} else {
|
return callback();
|
||||||
verified += ' ' + key;
|
}
|
||||||
};
|
// Verify debit cards
|
||||||
|
if (Array.isArray(data[key]['bitpayDebitCards-' + network])) {
|
||||||
|
for (var i = 0; i < data[key]['bitpayDebitCards-' + network].length; i++) {
|
||||||
|
if (!data[key]['bitpayDebitCards-' + network][i].token ||
|
||||||
|
!data[key]['bitpayDebitCards-' + network][i].eid ||
|
||||||
|
!data[key]['bitpayDebitCards-' + network][i].id ||
|
||||||
|
!data[key]['bitpayDebitCards-' + network][i].lastFourDigits) {
|
||||||
|
// Invalid entry - one or more keys are missing
|
||||||
|
toRemove.push(key);
|
||||||
|
return callback();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
verified += ' ' + key;
|
||||||
return callback();
|
return callback();
|
||||||
}, function() {
|
}, function() {
|
||||||
// done, remove invalid account entrys
|
// done, remove invalid account entrys
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue