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() {
|
||||
var network = self.coinbaseTestnet ? 'testnet' : 'livenet';
|
||||
storageService.getCoinbaseRefreshToken(network, function(err, refreshToken) {
|
||||
if (!refreshToken) return;
|
||||
coinbaseService.refreshToken(refreshToken, function(err, data) {
|
||||
if (err) {
|
||||
self.coinbaseError = err;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
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) {
|
||||
var network = testnet ? 'testnet' : 'livenet';
|
||||
|
|
@ -22,10 +22,10 @@ angular.module('copayApp.controllers').controller('preferencesCoinbaseController
|
|||
|
||||
modalInstance.result.then(function(ok) {
|
||||
if (ok) {
|
||||
storageService.removeCoinbaseToken(network, function() {
|
||||
coinbaseService.logout(network, function() {
|
||||
$timeout(function() {
|
||||
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;
|
||||
|
||||
});
|
||||
|
|
|
|||
|
|
@ -231,6 +231,10 @@ angular.module('copayApp.services')
|
|||
storage.get('coinbaseRefreshToken-' + network, cb);
|
||||
};
|
||||
|
||||
root.removeCoinbaseRefreshToken = function(network, cb) {
|
||||
storage.remove('coinbaseRefreshToken-' + network, cb);
|
||||
};
|
||||
|
||||
root.setCoinbaseToken = function(network, token, cb) {
|
||||
storage.set('coinbaseToken-' + network, token, cb);
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue