refactor identityService
This commit is contained in:
parent
ebe415a3d6
commit
ad87c4fc56
3 changed files with 26 additions and 20 deletions
|
|
@ -4,7 +4,7 @@ angular.module('copayApp.controllers').controller('CreateProfileController', fun
|
||||||
controllerUtils.redirIfLogged();
|
controllerUtils.redirIfLogged();
|
||||||
$scope.retreiving = true;
|
$scope.retreiving = true;
|
||||||
|
|
||||||
identityService.checkIdentity($scope);
|
identityService.check($scope);
|
||||||
|
|
||||||
$scope.createProfile = function(form) {
|
$scope.createProfile = function(form) {
|
||||||
if (form && form.$invalid) {
|
if (form && form.$invalid) {
|
||||||
|
|
@ -12,7 +12,7 @@ angular.module('copayApp.controllers').controller('CreateProfileController', fun
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$scope.loading = true;
|
$scope.loading = true;
|
||||||
identityService.createIdentity($scope, form);
|
identityService.create($scope, form);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ angular.module('copayApp.controllers').controller('HomeController', function($sc
|
||||||
controllerUtils.redirIfLogged();
|
controllerUtils.redirIfLogged();
|
||||||
$scope.retreiving = true;
|
$scope.retreiving = true;
|
||||||
|
|
||||||
identityService.checkIdentity($scope);
|
identityService.check($scope);
|
||||||
|
|
||||||
$scope.openProfile = function(form) {
|
$scope.openProfile = function(form) {
|
||||||
if (form && form.$invalid) {
|
if (form && form.$invalid) {
|
||||||
|
|
@ -12,20 +12,6 @@ angular.module('copayApp.controllers').controller('HomeController', function($sc
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$scope.loading = true;
|
$scope.loading = true;
|
||||||
copay.Identity.open(form.email.$modelValue, form.password.$modelValue, {
|
identityService.open($scope, form);
|
||||||
pluginManager: pluginManager,
|
|
||||||
network: config.network,
|
|
||||||
networkName: config.networkName,
|
|
||||||
walletDefaults: config.wallet,
|
|
||||||
passphraseConfig: config.passphraseConfig,
|
|
||||||
}, function(err, iden, lastFocusedWallet) {
|
|
||||||
if (err && !iden) {
|
|
||||||
console.log('Error:' + err)
|
|
||||||
controllerUtils.onErrorDigest(
|
|
||||||
$scope, (err.toString() || '').match('PNOTFOUND') ? 'Profile not found' : 'Unknown error');
|
|
||||||
} else {
|
|
||||||
controllerUtils.bindProfile($scope, iden, lastFocusedWallet);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ angular.module('copayApp.services')
|
||||||
.factory('identityService', function($rootScope, $location, pluginManager, controllerUtils) {
|
.factory('identityService', function($rootScope, $location, pluginManager, controllerUtils) {
|
||||||
var root = {};
|
var root = {};
|
||||||
|
|
||||||
root.checkIdentity = function (scope) {
|
root.check = function (scope) {
|
||||||
copay.Identity.anyProfile({
|
copay.Identity.anyProfile({
|
||||||
pluginManager: pluginManager,
|
pluginManager: pluginManager,
|
||||||
}, function(anyProfile) {
|
}, function(anyProfile) {
|
||||||
|
|
@ -22,7 +22,7 @@ angular.module('copayApp.services')
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
root.createIdentity = function (scope, form) {
|
root.create = function (scope, form) {
|
||||||
copay.Identity.create(form.email.$modelValue, form.password.$modelValue, {
|
copay.Identity.create(form.email.$modelValue, form.password.$modelValue, {
|
||||||
pluginManager: pluginManager,
|
pluginManager: pluginManager,
|
||||||
network: config.network,
|
network: config.network,
|
||||||
|
|
@ -35,6 +35,26 @@ angular.module('copayApp.services')
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
root.open = function (scope, form) {
|
||||||
|
copay.Identity.open(form.email.$modelValue, form.password.$modelValue, {
|
||||||
|
pluginManager: pluginManager,
|
||||||
|
network: config.network,
|
||||||
|
networkName: config.networkName,
|
||||||
|
walletDefaults: config.wallet,
|
||||||
|
passphraseConfig: config.passphraseConfig,
|
||||||
|
}, function(err, iden, lastFocusedWallet) {
|
||||||
|
if (err && !iden) {
|
||||||
|
console.log('Error:' + err)
|
||||||
|
controllerUtils.onErrorDigest(
|
||||||
|
scope, (err.toString() || '').match('PNOTFOUND') ? 'Profile not found' : 'Unknown error');
|
||||||
|
} else {
|
||||||
|
controllerUtils.bindProfile(scope, iden, lastFocusedWallet);
|
||||||
|
}
|
||||||
|
scope.loading = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
return root;
|
return root;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue