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
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);
|
||||
};
|
||||
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue