fix coinbase
This commit is contained in:
parent
ecf16d61ea
commit
d42e9f6896
2 changed files with 47 additions and 43 deletions
|
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
angular.module('copayApp.controllers').controller('coinbaseUriController',
|
||||
function($scope, $stateParams, $timeout, profileService, configService, coinbaseService, storageService, go) {
|
||||
function($scope, $stateParams, $timeout, profileService, configService, coinbaseService, storageService, go) {
|
||||
|
||||
this.submitOauthCode = function(code) {
|
||||
var self = this;
|
||||
|
|
@ -14,10 +14,9 @@ angular.module('copayApp.controllers').controller('coinbaseUriController',
|
|||
if (err) {
|
||||
self.error = err;
|
||||
$timeout(function() {
|
||||
$scope.$apply();
|
||||
}, 100);
|
||||
}
|
||||
else if (data && data.access_token && data.refresh_token) {
|
||||
$scope.$apply();
|
||||
}, 100);
|
||||
} else if (data && data.access_token && data.refresh_token) {
|
||||
storageService.setCoinbaseToken(network, data.access_token, function() {
|
||||
storageService.setCoinbaseRefreshToken(network, data.refresh_token, function() {
|
||||
$scope.$emit('Local/CoinbaseUpdated', data.access_token);
|
||||
|
|
@ -33,8 +32,13 @@ angular.module('copayApp.controllers').controller('coinbaseUriController',
|
|||
};
|
||||
|
||||
this.checkCode = function() {
|
||||
this.code = $stateParams.code;
|
||||
this.submitOauthCode(this.code);
|
||||
};
|
||||
|
||||
if ($stateParams.url) {
|
||||
var match = $stateParams.url.match(/code=(.+)&/);
|
||||
if (match && match[1]) {
|
||||
this.code = match[1];
|
||||
return this.submitOauthCode(this.code);
|
||||
}
|
||||
}
|
||||
$log.error('Bad state: ' + JSON.stringify($stateParams));
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,43 +1,43 @@
|
|||
'use strict';
|
||||
angular.module('copayApp.controllers').controller('glideraUriController',
|
||||
function($scope, $log, $stateParams, $timeout, profileService, configService, glideraService, storageService, go) {
|
||||
function($scope, $log, $stateParams, $timeout, profileService, configService, glideraService, storageService, go) {
|
||||
|
||||
this.submitOauthCode = function(code) {
|
||||
$log.debug('Glidera Oauth Code:' + code);
|
||||
var self = this;
|
||||
var glideraTestnet = configService.getSync().glidera.testnet;
|
||||
var network = glideraTestnet ? 'testnet' : 'livenet';
|
||||
this.loading = true;
|
||||
this.error = null;
|
||||
$timeout(function() {
|
||||
glideraService.getToken(code, function(err, data) {
|
||||
self.loading = null;
|
||||
if (err) {
|
||||
self.error = err;
|
||||
$timeout(function() {
|
||||
$scope.$apply();
|
||||
}, 100);
|
||||
} else if (data && data.access_token) {
|
||||
storageService.setGlideraToken(network, data.access_token, function() {
|
||||
$scope.$emit('Local/GlideraUpdated', data.access_token);
|
||||
this.submitOauthCode = function(code) {
|
||||
$log.debug('Glidera Oauth Code:' + code);
|
||||
var self = this;
|
||||
var glideraTestnet = configService.getSync().glidera.testnet;
|
||||
var network = glideraTestnet ? 'testnet' : 'livenet';
|
||||
this.loading = true;
|
||||
this.error = null;
|
||||
$timeout(function() {
|
||||
glideraService.getToken(code, function(err, data) {
|
||||
self.loading = null;
|
||||
if (err) {
|
||||
self.error = err;
|
||||
$timeout(function() {
|
||||
go.path('glidera');
|
||||
$scope.$apply();
|
||||
}, 100);
|
||||
});
|
||||
}
|
||||
});
|
||||
}, 100);
|
||||
};
|
||||
} else if (data && data.access_token) {
|
||||
storageService.setGlideraToken(network, data.access_token, function() {
|
||||
$scope.$emit('Local/GlideraUpdated', data.access_token);
|
||||
$timeout(function() {
|
||||
go.path('glidera');
|
||||
$scope.$apply();
|
||||
}, 100);
|
||||
});
|
||||
}
|
||||
});
|
||||
}, 100);
|
||||
};
|
||||
|
||||
this.checkCode = function() {
|
||||
if ($stateParams.url) {
|
||||
var match = $stateParams.url.match(/code=(.+)/);
|
||||
if (match && match[1]) {
|
||||
this.code = match[1];
|
||||
return this.submitOauthCode(this.code);
|
||||
this.checkCode = function() {
|
||||
if ($stateParams.url) {
|
||||
var match = $stateParams.url.match(/code=(.+)/);
|
||||
if (match && match[1]) {
|
||||
this.code = match[1];
|
||||
return this.submitOauthCode(this.code);
|
||||
}
|
||||
}
|
||||
$log.error('Bad state: ' + JSON.stringify($stateParams));
|
||||
}
|
||||
$log.error('Bad state: ' + JSON.stringify($stateParams));
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue