Simplified controllers with identityService
This commit is contained in:
parent
3c8caacc92
commit
ebe415a3d6
4 changed files with 46 additions and 26 deletions
40
js/services/identityService.js
Normal file
40
js/services/identityService.js
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.services')
|
||||
.factory('identityService', function($rootScope, $location, pluginManager, controllerUtils) {
|
||||
var root = {};
|
||||
|
||||
root.checkIdentity = function (scope) {
|
||||
copay.Identity.anyProfile({
|
||||
pluginManager: pluginManager,
|
||||
}, function(anyProfile) {
|
||||
copay.Identity.anyWallet({
|
||||
pluginManager: pluginManager,
|
||||
}, function(anyWallet) {
|
||||
scope.retreiving = false;
|
||||
scope.anyProfile = anyProfile ? true : false;
|
||||
scope.anyWallet = anyWallet ? true : false;
|
||||
|
||||
if (!scope.anyProfile) {
|
||||
$location.path('/createProfile');
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
root.createIdentity = function (scope, form) {
|
||||
copay.Identity.create(form.email.$modelValue, form.password.$modelValue, {
|
||||
pluginManager: pluginManager,
|
||||
network: config.network,
|
||||
networkName: config.networkName,
|
||||
walletDefaults: config.wallet,
|
||||
passphraseConfig: config.passphraseConfig,
|
||||
}, function(err, iden, firstWallet) {
|
||||
controllerUtils.bindProfile(scope, iden, firstWallet);
|
||||
scope.loading = false;
|
||||
});
|
||||
};
|
||||
|
||||
return root;
|
||||
});
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue