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';
|
'use strict';
|
||||||
angular.module('copayApp.controllers').controller('coinbaseUriController',
|
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) {
|
this.submitOauthCode = function(code) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
@ -14,10 +14,9 @@ angular.module('copayApp.controllers').controller('coinbaseUriController',
|
||||||
if (err) {
|
if (err) {
|
||||||
self.error = err;
|
self.error = err;
|
||||||
$timeout(function() {
|
$timeout(function() {
|
||||||
$scope.$apply();
|
$scope.$apply();
|
||||||
}, 100);
|
}, 100);
|
||||||
}
|
} else if (data && data.access_token && data.refresh_token) {
|
||||||
else if (data && data.access_token && data.refresh_token) {
|
|
||||||
storageService.setCoinbaseToken(network, data.access_token, function() {
|
storageService.setCoinbaseToken(network, data.access_token, function() {
|
||||||
storageService.setCoinbaseRefreshToken(network, data.refresh_token, function() {
|
storageService.setCoinbaseRefreshToken(network, data.refresh_token, function() {
|
||||||
$scope.$emit('Local/CoinbaseUpdated', data.access_token);
|
$scope.$emit('Local/CoinbaseUpdated', data.access_token);
|
||||||
|
|
@ -33,8 +32,13 @@ angular.module('copayApp.controllers').controller('coinbaseUriController',
|
||||||
};
|
};
|
||||||
|
|
||||||
this.checkCode = function() {
|
this.checkCode = function() {
|
||||||
this.code = $stateParams.code;
|
if ($stateParams.url) {
|
||||||
this.submitOauthCode(this.code);
|
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';
|
'use strict';
|
||||||
angular.module('copayApp.controllers').controller('glideraUriController',
|
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) {
|
this.submitOauthCode = function(code) {
|
||||||
$log.debug('Glidera Oauth Code:' + code);
|
$log.debug('Glidera Oauth Code:' + code);
|
||||||
var self = this;
|
var self = this;
|
||||||
var glideraTestnet = configService.getSync().glidera.testnet;
|
var glideraTestnet = configService.getSync().glidera.testnet;
|
||||||
var network = glideraTestnet ? 'testnet' : 'livenet';
|
var network = glideraTestnet ? 'testnet' : 'livenet';
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
this.error = null;
|
this.error = null;
|
||||||
$timeout(function() {
|
$timeout(function() {
|
||||||
glideraService.getToken(code, function(err, data) {
|
glideraService.getToken(code, function(err, data) {
|
||||||
self.loading = null;
|
self.loading = null;
|
||||||
if (err) {
|
if (err) {
|
||||||
self.error = 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);
|
|
||||||
$timeout(function() {
|
$timeout(function() {
|
||||||
go.path('glidera');
|
|
||||||
$scope.$apply();
|
$scope.$apply();
|
||||||
}, 100);
|
}, 100);
|
||||||
});
|
} else if (data && data.access_token) {
|
||||||
}
|
storageService.setGlideraToken(network, data.access_token, function() {
|
||||||
});
|
$scope.$emit('Local/GlideraUpdated', data.access_token);
|
||||||
}, 100);
|
$timeout(function() {
|
||||||
};
|
go.path('glidera');
|
||||||
|
$scope.$apply();
|
||||||
|
}, 100);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}, 100);
|
||||||
|
};
|
||||||
|
|
||||||
this.checkCode = function() {
|
this.checkCode = function() {
|
||||||
if ($stateParams.url) {
|
if ($stateParams.url) {
|
||||||
var match = $stateParams.url.match(/code=(.+)/);
|
var match = $stateParams.url.match(/code=(.+)/);
|
||||||
if (match && match[1]) {
|
if (match && match[1]) {
|
||||||
this.code = match[1];
|
this.code = match[1];
|
||||||
return this.submitOauthCode(this.code);
|
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