Simplified controllers with identityService

This commit is contained in:
Gustavo Maximiliano Cortez 2014-10-24 11:37:03 -03:00
commit ebe415a3d6
4 changed files with 46 additions and 26 deletions

View file

@ -1,23 +1,10 @@
'use strict';
angular.module('copayApp.controllers').controller('CreateProfileController', function($scope, $rootScope, $location, notification, controllerUtils, pluginManager) {
angular.module('copayApp.controllers').controller('CreateProfileController', function($scope, $rootScope, $location, notification, controllerUtils, pluginManager, identityService) {
controllerUtils.redirIfLogged();
$scope.retreiving = true;
copay.Identity.anyProfile({
pluginManager: pluginManager,
}, function(anyProfile) {
copay.Identity.anyWallet({
pluginManager: pluginManager,
}, function(anyWallet) {
$scope.retreiving = false;
$scope.anyProfile = anyProfile;
$scope.anyWallet = anyWallet;
});
});
identityService.checkIdentity($scope);
$scope.createProfile = function(form) {
if (form && form.$invalid) {
@ -25,15 +12,7 @@ angular.module('copayApp.controllers').controller('CreateProfileController', fun
return;
}
$scope.loading = true;
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);
});
identityService.createIdentity($scope, form);
}
});