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) {

View file

@ -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',

View file

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

View file

@ -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) {

View file

@ -7,16 +7,10 @@
<ion-content>
<div class="box-notification warning m0" ng-show="network == 'testnet'">
Testnet wallets only work with Coinbase Sandbox Accounts
</div>
<div class="text-center" ng-show="error">
<div class="m20b box-notification" ng-show="error">
<ul class="no-bullet m0 size-12">
<li ng-repeat="err in error.errors" ng-bind-html="err.message"></li>
</ul>
</div>
<div class="box-notification error" ng-show="error">
<ul class="no-bullet m0 size-12">
<li ng-repeat="err in error.errors" ng-bind-html="err.message"></li>
</ul>
</div>
<div ng-if="!accountId && !error" ng-init="showOauthForm = false">
@ -28,7 +22,7 @@
<p class="m20t text-gray size-12">Connect your Coinbase account to get started</p>
<button class="button button-standard button-primary"
ng-click="coinbase.openAuthenticateWindow(); showOauthForm = true">
ng-click="coinbase.openAuthenticateWindow()">
Connect to Coinbase
</button>
<div class="m20t">

View file

@ -54,7 +54,7 @@
<div class="item item-divider"></div>
<li class="item" ng-click="revokeToken()">
<span>Log out</span>
<span class="assertive">Log out</span>
</li>
</ul>