Fix uri handler for coinbase

This commit is contained in:
Gustavo Maximiliano Cortez 2017-01-03 12:43:08 -03:00
commit 5301d1e9a9
No known key found for this signature in database
GPG key ID: 15EDAD8D9F2EB1AF
7 changed files with 27 additions and 24 deletions

View file

@ -3,6 +3,7 @@
angular.module('copayApp.controllers').controller('coinbaseController', function($rootScope, $scope, $timeout, $ionicModal, $log, profileService, configService, storageService, coinbaseService, lodash, platformInfo, ongoingProcess, popupService, gettextCatalog, externalLinkService) {
var isNW = platformInfo.isNW;
var isCordova = platformInfo.isCordova;
var init = function() {
ongoingProcess.set('connectingCoinbase', true);
@ -58,6 +59,7 @@ angular.module('copayApp.controllers').controller('coinbaseController', function
}
this.getAuthenticateUrl = function() {
$scope.showOauthForm = isCordova || isNW ? false : true;
return coinbaseService.getOauthCodeUrl();
};
@ -90,9 +92,13 @@ angular.module('copayApp.controllers').controller('coinbaseController', function
});
};
var self = this;
$scope.$on("$ionicView.beforeEnter", function(event, data) {
coinbaseService.setCredentials();
$scope.network = coinbaseService.getEnvironment();
init();
if (data.stateParams && data.stateParams.code) {
self.submitOauthCode(data.stateParams.code);
} else {
init();
}
});
});

View file

@ -19,8 +19,7 @@ angular.module('copayApp.controllers').controller('preferencesCoinbaseController
coinbaseService.setCredentials();
$scope.network = coinbaseService.getEnvironment();
ongoingProcess.set('connectingCoinbase', true);
coinbaseService.init($scope.accessToken, function(err, data) {
ongoingProcess.set('connectingCoinbase', false);
coinbaseService.init(function(err, data) {
if (err || lodash.isEmpty(data)) {
ongoingProcess.set('connectingCoinbase', false);
if (err) {
@ -31,6 +30,7 @@ angular.module('copayApp.controllers').controller('preferencesCoinbaseController
var accessToken = data.accessToken;
var accountId = data.accountId;
coinbaseService.getAccount(accessToken, accountId, function(err, account) {
ongoingProcess.set('connectingCoinbase', false);
$scope.coinbaseAccount = account.data;
});
coinbaseService.getCurrentUser(accessToken, function(err, user) {