Wallet/src/js/controllers/glideraUri.js

40 lines
1.3 KiB
JavaScript
Raw Normal View History

'use strict';
angular.module('copayApp.controllers').controller('glideraUriController',
function($scope, $stateParams, $timeout, profileService, configService, glideraService, storageService, go) {
this.submitOauthCode = function(code) {
console.log('[glideraUri.js.5:code:]'+code); //TODO
var self = this;
var glideraTestnet = configService.getSync().glidera.testnet;
var network = glideraTestnet ? 'testnet' : 'livenet';
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(network, data.access_token, function() {
2015-09-11 13:11:41 -03:00
$scope.$emit('Local/GlideraUpdated', data.access_token);
$timeout(function() {
go.path('glidera');
$scope.$apply();
}, 100);
});
}
});
}, 100);
};
this.checkCode = function() {
console.log('[glideraUri.js.35:$stateParams:]' + JSON.stringify($stateParams)); //TODO
this.code = $stateParams.code;
this.submitOauthCode(this.code);
};
});