Fix coinbase logout for some cases where refreshToken tries to connect again (#4155)
This commit is contained in:
parent
dff2a7604a
commit
b8c2ff863d
4 changed files with 16 additions and 3 deletions
|
|
@ -1419,6 +1419,7 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
||||||
self.refreshCoinbaseToken = function() {
|
self.refreshCoinbaseToken = function() {
|
||||||
var network = self.coinbaseTestnet ? 'testnet' : 'livenet';
|
var network = self.coinbaseTestnet ? 'testnet' : 'livenet';
|
||||||
storageService.getCoinbaseRefreshToken(network, function(err, refreshToken) {
|
storageService.getCoinbaseRefreshToken(network, function(err, refreshToken) {
|
||||||
|
if (!refreshToken) return;
|
||||||
coinbaseService.refreshToken(refreshToken, function(err, data) {
|
coinbaseService.refreshToken(refreshToken, function(err, data) {
|
||||||
if (err) {
|
if (err) {
|
||||||
self.coinbaseError = err;
|
self.coinbaseError = err;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('copayApp.controllers').controller('preferencesCoinbaseController',
|
angular.module('copayApp.controllers').controller('preferencesCoinbaseController',
|
||||||
function($scope, $modal, $timeout, applicationService, coinbaseService, storageService, animationService) {
|
function($scope, $modal, $timeout, applicationService, coinbaseService, animationService) {
|
||||||
|
|
||||||
this.revokeToken = function(testnet) {
|
this.revokeToken = function(testnet) {
|
||||||
var network = testnet ? 'testnet' : 'livenet';
|
var network = testnet ? 'testnet' : 'livenet';
|
||||||
|
|
@ -22,10 +22,10 @@ angular.module('copayApp.controllers').controller('preferencesCoinbaseController
|
||||||
|
|
||||||
modalInstance.result.then(function(ok) {
|
modalInstance.result.then(function(ok) {
|
||||||
if (ok) {
|
if (ok) {
|
||||||
storageService.removeCoinbaseToken(network, function() {
|
coinbaseService.logout(network, function() {
|
||||||
$timeout(function() {
|
$timeout(function() {
|
||||||
applicationService.restart();
|
applicationService.restart();
|
||||||
}, 100);
|
}, 1000);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -361,6 +361,14 @@ angular.module('copayApp.services').factory('coinbaseService', function($http, $
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
root.logout = function(network, cb) {
|
||||||
|
storageService.removeCoinbaseToken(network, function() {
|
||||||
|
storageService.removeCoinbaseRefreshToken(network, function() {
|
||||||
|
return cb();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
return root;
|
return root;
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -231,6 +231,10 @@ angular.module('copayApp.services')
|
||||||
storage.get('coinbaseRefreshToken-' + network, cb);
|
storage.get('coinbaseRefreshToken-' + network, cb);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
root.removeCoinbaseRefreshToken = function(network, cb) {
|
||||||
|
storage.remove('coinbaseRefreshToken-' + network, cb);
|
||||||
|
};
|
||||||
|
|
||||||
root.setCoinbaseToken = function(network, token, cb) {
|
root.setCoinbaseToken = function(network, token, cb) {
|
||||||
storage.set('coinbaseToken-' + network, token, cb);
|
storage.set('coinbaseToken-' + network, token, cb);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue