Fix uri handler for coinbase
This commit is contained in:
parent
1a586f6fcc
commit
5301d1e9a9
7 changed files with 27 additions and 24 deletions
|
|
@ -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) {
|
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 isNW = platformInfo.isNW;
|
||||||
|
var isCordova = platformInfo.isCordova;
|
||||||
|
|
||||||
var init = function() {
|
var init = function() {
|
||||||
ongoingProcess.set('connectingCoinbase', true);
|
ongoingProcess.set('connectingCoinbase', true);
|
||||||
|
|
@ -58,6 +59,7 @@ angular.module('copayApp.controllers').controller('coinbaseController', function
|
||||||
}
|
}
|
||||||
|
|
||||||
this.getAuthenticateUrl = function() {
|
this.getAuthenticateUrl = function() {
|
||||||
|
$scope.showOauthForm = isCordova || isNW ? false : true;
|
||||||
return coinbaseService.getOauthCodeUrl();
|
return coinbaseService.getOauthCodeUrl();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -90,9 +92,13 @@ angular.module('copayApp.controllers').controller('coinbaseController', function
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var self = this;
|
||||||
$scope.$on("$ionicView.beforeEnter", function(event, data) {
|
$scope.$on("$ionicView.beforeEnter", function(event, data) {
|
||||||
coinbaseService.setCredentials();
|
coinbaseService.setCredentials();
|
||||||
$scope.network = coinbaseService.getEnvironment();
|
if (data.stateParams && data.stateParams.code) {
|
||||||
init();
|
self.submitOauthCode(data.stateParams.code);
|
||||||
|
} else {
|
||||||
|
init();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,7 @@ angular.module('copayApp.controllers').controller('preferencesCoinbaseController
|
||||||
coinbaseService.setCredentials();
|
coinbaseService.setCredentials();
|
||||||
$scope.network = coinbaseService.getEnvironment();
|
$scope.network = coinbaseService.getEnvironment();
|
||||||
ongoingProcess.set('connectingCoinbase', true);
|
ongoingProcess.set('connectingCoinbase', true);
|
||||||
coinbaseService.init($scope.accessToken, function(err, data) {
|
coinbaseService.init(function(err, data) {
|
||||||
ongoingProcess.set('connectingCoinbase', false);
|
|
||||||
if (err || lodash.isEmpty(data)) {
|
if (err || lodash.isEmpty(data)) {
|
||||||
ongoingProcess.set('connectingCoinbase', false);
|
ongoingProcess.set('connectingCoinbase', false);
|
||||||
if (err) {
|
if (err) {
|
||||||
|
|
@ -31,6 +30,7 @@ angular.module('copayApp.controllers').controller('preferencesCoinbaseController
|
||||||
var accessToken = data.accessToken;
|
var accessToken = data.accessToken;
|
||||||
var accountId = data.accountId;
|
var accountId = data.accountId;
|
||||||
coinbaseService.getAccount(accessToken, accountId, function(err, account) {
|
coinbaseService.getAccount(accessToken, accountId, function(err, account) {
|
||||||
|
ongoingProcess.set('connectingCoinbase', false);
|
||||||
$scope.coinbaseAccount = account.data;
|
$scope.coinbaseAccount = account.data;
|
||||||
});
|
});
|
||||||
coinbaseService.getCurrentUser(accessToken, function(err, user) {
|
coinbaseService.getCurrentUser(accessToken, function(err, user) {
|
||||||
|
|
|
||||||
|
|
@ -142,10 +142,6 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr
|
||||||
controller: 'glideraUriController',
|
controller: 'glideraUriController',
|
||||||
templateUrl: 'views/glideraUri.html'
|
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', {
|
.state('tabs.buyandsell.coinbase', {
|
||||||
url: '/coinbase',
|
url: '/coinbase/:code',
|
||||||
views: {
|
views: {
|
||||||
'tab-home@tabs': {
|
'tab-home@tabs': {
|
||||||
controller: 'coinbaseController',
|
controller: 'coinbaseController',
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ angular.module('copayApp.services').factory('coinbaseService', function($http, $
|
||||||
+ 'wallet:payment-methods:read';
|
+ 'wallet:payment-methods:read';
|
||||||
|
|
||||||
// NW has a bug with Window Object
|
// NW has a bug with Window Object
|
||||||
if (isCordova && isNW) {
|
if (isCordova || isNW) {
|
||||||
credentials.REDIRECT_URI = coinbase.redirect_uri.mobile;
|
credentials.REDIRECT_URI = coinbase.redirect_uri.mobile;
|
||||||
} else {
|
} else {
|
||||||
credentials.REDIRECT_URI = coinbase.redirect_uri.desktop;
|
credentials.REDIRECT_URI = coinbase.redirect_uri.desktop;
|
||||||
|
|
|
||||||
|
|
@ -126,9 +126,16 @@ angular.module('copayApp.services').factory('incomingData', function($log, $stat
|
||||||
url: data
|
url: data
|
||||||
});
|
});
|
||||||
} else if (data && data.indexOf(appConfigService.name + '://coinbase') === 0) {
|
} else if (data && data.indexOf(appConfigService.name + '://coinbase') === 0) {
|
||||||
return $state.go('uricoinbase', {
|
var code = getParameterByName('code', data);
|
||||||
url: 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
|
// BitPayCard Authentication
|
||||||
} else if (data && data.indexOf(appConfigService.name + '://') === 0) {
|
} else if (data && data.indexOf(appConfigService.name + '://') === 0) {
|
||||||
|
|
|
||||||
|
|
@ -7,16 +7,10 @@
|
||||||
|
|
||||||
<ion-content>
|
<ion-content>
|
||||||
|
|
||||||
<div class="box-notification warning m0" ng-show="network == 'testnet'">
|
<div class="box-notification error" ng-show="error">
|
||||||
Testnet wallets only work with Coinbase Sandbox Accounts
|
<ul class="no-bullet m0 size-12">
|
||||||
</div>
|
<li ng-repeat="err in error.errors" ng-bind-html="err.message"></li>
|
||||||
|
</ul>
|
||||||
<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>
|
</div>
|
||||||
|
|
||||||
<div ng-if="!accountId && !error" ng-init="showOauthForm = false">
|
<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>
|
<p class="m20t text-gray size-12">Connect your Coinbase account to get started</p>
|
||||||
|
|
||||||
<button class="button button-standard button-primary"
|
<button class="button button-standard button-primary"
|
||||||
ng-click="coinbase.openAuthenticateWindow(); showOauthForm = true">
|
ng-click="coinbase.openAuthenticateWindow()">
|
||||||
Connect to Coinbase
|
Connect to Coinbase
|
||||||
</button>
|
</button>
|
||||||
<div class="m20t">
|
<div class="m20t">
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@
|
||||||
|
|
||||||
<div class="item item-divider"></div>
|
<div class="item item-divider"></div>
|
||||||
<li class="item" ng-click="revokeToken()">
|
<li class="item" ng-click="revokeToken()">
|
||||||
<span>Log out</span>
|
<span class="assertive">Log out</span>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue