diff --git a/src/js/controllers/coinbase.js b/src/js/controllers/coinbase.js index e1bc21e17..f5ab4368e 100644 --- a/src/js/controllers/coinbase.js +++ b/src/js/controllers/coinbase.js @@ -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(); + } }); }); diff --git a/src/js/controllers/preferencesCoinbase.js b/src/js/controllers/preferencesCoinbase.js index b9113cbcd..beb39dc26 100644 --- a/src/js/controllers/preferencesCoinbase.js +++ b/src/js/controllers/preferencesCoinbase.js @@ -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) { diff --git a/src/js/routes.js b/src/js/routes.js index 57d5b57d8..38ae9331a 100644 --- a/src/js/routes.js +++ b/src/js/routes.js @@ -142,10 +142,6 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr controller: 'glideraUriController', templateUrl: 'views/glideraUri.html' }) - .state('uricoinbase', { - url: '/uri-coinbase/:url', - templateUrl: 'views/coinbaseUri.html' - }) /* * @@ -927,7 +923,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr */ .state('tabs.buyandsell.coinbase', { - url: '/coinbase', + url: '/coinbase/:code', views: { 'tab-home@tabs': { controller: 'coinbaseController', diff --git a/src/js/services/coinbaseService.js b/src/js/services/coinbaseService.js index f0267eb1d..90e0c5622 100644 --- a/src/js/services/coinbaseService.js +++ b/src/js/services/coinbaseService.js @@ -61,7 +61,7 @@ angular.module('copayApp.services').factory('coinbaseService', function($http, $ + 'wallet:payment-methods:read'; // NW has a bug with Window Object - if (isCordova && isNW) { + if (isCordova || isNW) { credentials.REDIRECT_URI = coinbase.redirect_uri.mobile; } else { credentials.REDIRECT_URI = coinbase.redirect_uri.desktop; diff --git a/src/js/services/incomingData.js b/src/js/services/incomingData.js index 4b7d4ea34..78e856af1 100644 --- a/src/js/services/incomingData.js +++ b/src/js/services/incomingData.js @@ -126,9 +126,16 @@ angular.module('copayApp.services').factory('incomingData', function($log, $stat url: data }); } else if (data && data.indexOf(appConfigService.name + '://coinbase') === 0) { - return $state.go('uricoinbase', { - url: data + var code = getParameterByName('code', data); + $state.go('tabs.home', {}, { + 'reload': true, + 'notify': $state.current.name == 'tabs.home' ? false : true + }).then(function() { + $state.transitionTo('tabs.buyandsell.coinbase', { + code: code + }); }); + return true; // BitPayCard Authentication } else if (data && data.indexOf(appConfigService.name + '://') === 0) { diff --git a/www/views/coinbase.html b/www/views/coinbase.html index a8cae44a4..1ec941348 100644 --- a/www/views/coinbase.html +++ b/www/views/coinbase.html @@ -7,16 +7,10 @@ -
- Testnet wallets only work with Coinbase Sandbox Accounts -
- -
-
-
    -
  • -
-
+
+
    +
  • +
@@ -28,7 +22,7 @@

Connect your Coinbase account to get started

diff --git a/www/views/preferencesCoinbase.html b/www/views/preferencesCoinbase.html index 3b0e0599c..68050e9af 100644 --- a/www/views/preferencesCoinbase.html +++ b/www/views/preferencesCoinbase.html @@ -54,7 +54,7 @@
  • - Log out + Log out