Fix coinbase logout for some cases where refreshToken tries to connect again (#4155)

This commit is contained in:
Gustavo Maximiliano Cortez 2016-04-29 10:27:46 -03:00
commit b8c2ff863d
No known key found for this signature in database
GPG key ID: 15EDAD8D9F2EB1AF
4 changed files with 16 additions and 3 deletions

View file

@ -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;

View file

@ -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);
});
}
});

View file

@ -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;
});

View file

@ -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);
};