URL handler to return the code after send a request for access token
This commit is contained in:
parent
b76c6fe5a0
commit
38a4919f01
7 changed files with 108 additions and 13 deletions
|
|
@ -66,11 +66,10 @@
|
||||||
Testnet wallets only work with Glidera Sandbox Accounts
|
Testnet wallets only work with Glidera Sandbox Accounts
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button
|
<a class="button dark-gray outline round tiny"
|
||||||
class="dark-gray outline round tiny"
|
ng-click="$root.openExternalLink(glidera.getAuthenticateUrl(), '_system'); showOauthForm = true" translate>
|
||||||
ng-click="$root.openExternalLink(glidera.getAuthenticateUrl()); showOauthForm = true" translate>
|
|
||||||
Connect to Glidera
|
Connect to Glidera
|
||||||
</button>
|
</a>
|
||||||
<div>
|
<div>
|
||||||
<a href ng-click="showOauthForm = true" class="text-gray size-12">
|
<a href ng-click="showOauthForm = true" class="text-gray size-12">
|
||||||
Do you already have the Oauth Code?
|
Do you already have the Oauth Code?
|
||||||
|
|
|
||||||
35
public/views/glideraUri.html
Normal file
35
public/views/glideraUri.html
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
<div
|
||||||
|
class="topbar-container"
|
||||||
|
ng-include="'views/includes/topbar.html'"
|
||||||
|
ng-init="titleSection='Glidera'; closeToHome = true">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="content glidera" ng-controller="glideraUriController as glidera" ng-init="glidera.checkCode()">
|
||||||
|
|
||||||
|
<div class="onGoingProcess" ng-show="glidera.loading">
|
||||||
|
<div class="onGoingProcess-content" ng-style="{'background-color':index.backgroundColor}">
|
||||||
|
<div class="spinner">
|
||||||
|
<div class="rect1"></div>
|
||||||
|
<div class="rect2"></div>
|
||||||
|
<div class="rect3"></div>
|
||||||
|
<div class="rect4"></div>
|
||||||
|
<div class="rect5"></div>
|
||||||
|
</div>
|
||||||
|
<span ng-show="glidera.loading" translate>Connecting to Glidera...</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row m20t">
|
||||||
|
<div class="large-12 columns">
|
||||||
|
<div class="text-center">
|
||||||
|
<img src="img/glidera-logo.png"
|
||||||
|
ng-click="index.updateGlidera(index.glideraToken, index.glideraPermissions)" width="100">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="m10t text-center" ng-show="glidera.error">
|
||||||
|
<div class="notification m10b size-12 text-warning">{{glidera.error}}</div>
|
||||||
|
<button class="outline dark-gray tiny round" ng-click="glidera.submitOauthCode(glidera.code)">Try again</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
37
src/js/controllers/glideraUri.js
Normal file
37
src/js/controllers/glideraUri.js
Normal file
|
|
@ -0,0 +1,37 @@
|
||||||
|
'use strict';
|
||||||
|
angular.module('copayApp.controllers').controller('glideraUriController',
|
||||||
|
function($scope, $stateParams, $timeout, profileService, glideraService, storageService, go) {
|
||||||
|
|
||||||
|
this.submitOauthCode = function(code) {
|
||||||
|
var fc = profileService.focusedClient;
|
||||||
|
var self = this;
|
||||||
|
this.loading = true;
|
||||||
|
this.error = null;
|
||||||
|
$timeout(function() {
|
||||||
|
glideraService.getToken(code, function(err, data) {
|
||||||
|
self.loading = null;
|
||||||
|
if (err) {
|
||||||
|
self.error = err;
|
||||||
|
$timeout(function() {
|
||||||
|
$scope.$apply();
|
||||||
|
}, 100);
|
||||||
|
}
|
||||||
|
else if (data && data.access_token) {
|
||||||
|
storageService.setGlideraToken(fc.credentials.network, data.access_token, function() {
|
||||||
|
$scope.$emit('Local/GlideraTokenUpdated', data.access_token);
|
||||||
|
$timeout(function() {
|
||||||
|
go.path('glidera');
|
||||||
|
$scope.$apply();
|
||||||
|
}, 100);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}, 100);
|
||||||
|
};
|
||||||
|
|
||||||
|
this.checkCode = function() {
|
||||||
|
this.code = $stateParams.code;
|
||||||
|
this.submitOauthCode(this.code);
|
||||||
|
};
|
||||||
|
|
||||||
|
});
|
||||||
|
|
@ -9,8 +9,14 @@ angular.element(document).ready(function() {
|
||||||
|
|
||||||
var handleBitcoinURI = function(url) {
|
var handleBitcoinURI = function(url) {
|
||||||
if (!url) return;
|
if (!url) return;
|
||||||
|
if (url.indexOf('glidera') != -1) {
|
||||||
|
url = '#/uri-glidera' + url.replace('bitcoin://glidera', '');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
url = '#/uri-payment/' + url;
|
||||||
|
}
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
window.location = '#/uri-payment/' + url;
|
window.location = url;
|
||||||
}, 1000);
|
}, 1000);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -288,6 +288,15 @@ angular
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
.state('uriglidera', {
|
||||||
|
url: '/uri-glidera?code',
|
||||||
|
needProfile: true,
|
||||||
|
views: {
|
||||||
|
'main': {
|
||||||
|
templateUrl: 'views/glideraUri.html'
|
||||||
|
},
|
||||||
|
}
|
||||||
|
})
|
||||||
.state('glidera', {
|
.state('glidera', {
|
||||||
url: '/glidera',
|
url: '/glidera',
|
||||||
walletShouldBeComplete: true,
|
walletShouldBeComplete: true,
|
||||||
|
|
@ -527,6 +536,7 @@ angular
|
||||||
copayers: -1,
|
copayers: -1,
|
||||||
cordova: -1,
|
cordova: -1,
|
||||||
payment: -1,
|
payment: -1,
|
||||||
|
uriglidera: -1,
|
||||||
|
|
||||||
preferences: 11,
|
preferences: 11,
|
||||||
glidera: 11,
|
glidera: 11,
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,22 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('copayApp.services').factory('glideraService', function($http, $log) {
|
angular.module('copayApp.services').factory('glideraService', function($http, $log, isCordova) {
|
||||||
var root = {};
|
var root = {};
|
||||||
var credentials = {};
|
var credentials = {};
|
||||||
|
|
||||||
root.setCredentials = function(network) {
|
root.setCredentials = function(network) {
|
||||||
if (network == 'testnet') {
|
if (network == 'testnet') {
|
||||||
credentials.HOST = 'https://sandbox.glidera.io';
|
credentials.HOST = 'https://sandbox.glidera.io';
|
||||||
credentials.REDIRECT_URI = 'urn:ietf:wg:oauth:2.0:oob';
|
if (isCordova) {
|
||||||
credentials.CLIENT_ID = '9915b6ffa6dc3baffb87135ed3873d49';
|
credentials.REDIRECT_URI = 'bitcoin://glidera';
|
||||||
credentials.CLIENT_SECRET = 'd74eda05b9c6a228fd5c85cfbd0eb7eb';
|
credentials.CLIENT_ID = 'dfc56e4336e32bb8ba46dde34f3d7d6d';
|
||||||
|
credentials.CLIENT_SECRET = '5eb679058f6c7eb81123162323d4fba5';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
credentials.REDIRECT_URI = 'urn:ietf:wg:oauth:2.0:oob';
|
||||||
|
credentials.CLIENT_ID = '9915b6ffa6dc3baffb87135ed3873d49';
|
||||||
|
credentials.CLIENT_SECRET = 'd74eda05b9c6a228fd5c85cfbd0eb7eb';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
credentials.HOST = 'https://glidera.io';
|
credentials.HOST = 'https://glidera.io';
|
||||||
|
|
|
||||||
|
|
@ -29,12 +29,13 @@ angular.module('copayApp.services').factory('go', function($window, $rootScope,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
root.openExternalLink = function(url) {
|
root.openExternalLink = function(url, target) {
|
||||||
if (nodeWebkit.isDefined()) {
|
if (nodeWebkit.isDefined()) {
|
||||||
nodeWebkit.openExternalLink(url);
|
nodeWebkit.openExternalLink(url);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
var ref = window.open(url, '_blank', 'location=no');
|
target = target || '_blank';
|
||||||
|
var ref = window.open(url, target, 'location=no');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -89,8 +90,8 @@ angular.module('copayApp.services').factory('go', function($window, $rootScope,
|
||||||
root.path(path);
|
root.path(path);
|
||||||
};
|
};
|
||||||
|
|
||||||
$rootScope.openExternalLink = function(url) {
|
$rootScope.openExternalLink = function(url, target) {
|
||||||
root.openExternalLink(url);
|
root.openExternalLink(url, target);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue